Skip to content

Add twig vue js tip #13909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions frontend/encore/vuejs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,24 @@ you can import them with ``require()`` function:
}
}

Embeded with Twig
-----------------

You can of course, inside a Twig template rendered from a controller,
instantiate a Vue.js app as any other JavaScript code.

.. tip::

You may in this case leverage the delimiters options
to not overlap with Twig ones.
For example, using `delimiters: ['${', '}$']` inside the Vue.js instance.

.. code-block:: twig

{{ twig_var }} renders a Twig variable
${ vuejs_var }$ renders a Vue.js variable


.. _`Vue.js`: https://vuejs.org/
.. _`vue-loader options`: https://vue-loader.vuejs.org/options.html
.. _`Encore's index.js file`: https://github.com/symfony/webpack-encore/blob/master/index.js
Expand Down