Suppose I have
<div id="myDiv"></div>
I want to set its content to "Some text".
Is it possible?
Something like
{% set id.myDiv = "Some text" %}
Edit
Well, despite the fact it is not, Lindsey D solved my problem in the BEST way.
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communitySuppose I have
<div id="myDiv"></div>
I want to set its content to "Some text".
Is it possible?
Something like
{% set id.myDiv = "Some text" %}
Edit
Well, despite the fact it is not, Lindsey D solved my problem in the BEST way.
No disrespect, but you may be misunderstanding the relationship between Twig and HTML.
The Twig code is completely oblivious to your HTML DOM structure. Its job is to parse any Twig tags into PHP (which are then ultimately rendered in HTML).
Based on your example, try it like this:
{% set myDiv = "Some text" %}
<div id="myDiv">{{ myDiv }}</div>
To expand further on the relationship between Twig/PHP/HTML, think of it like this...
(1) Twig is parsed on the server. It generates a PHP file which represents your entire Twig file. That PHP file is stored until a change is made to your Twig template. Assuming nothing has changed, Twig will then call that PHP file directly (bypassing the original Twig file).
(2) PHP will then do everything it needs to do, again on the server. It will finish rendering whatever HTML it needs to, before sending back that fully-parsed HTML to the client.
(3) Once you get the the client side, it's all HTML (and CSS and JS). There is no more PHP or Twig.