Skip to content

Commit 3bf6394

Browse files
94nonijaviereguiluz
authored andcommitted
Add twig vue js tip
1 parent 7551c92 commit 3bf6394

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

frontend/encore/vuejs.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,24 @@ you can import them with ``require()`` function:
155155
}
156156
}
157157
158+
Embeded with Twig
159+
-----------------
160+
161+
You can of course, inside a Twig template rendered from a controller,
162+
instantiate a Vue.js app as any other JavaScript code.
163+
164+
.. tip::
165+
166+
You may in this case leverage the delimiters options
167+
to not overlap with Twig ones.
168+
For example, using `delimiters: ['${', '}$']` inside the Vue.js instance.
169+
170+
.. code-block:: twig
171+
172+
{{ twig_var }} renders a Twig variable
173+
${ vuejs_var }$ renders a Vue.js variable
174+
175+
158176
.. _`Vue.js`: https://vuejs.org/
159177
.. _`vue-loader options`: https://vue-loader.vuejs.org/options.html
160178
.. _`Encore's index.js file`: https://github.com/symfony/webpack-encore/blob/master/index.js

0 commit comments

Comments
 (0)