Note that there are some explanatory texts on larger screens.

plurals
  1. POTemplating regex versus DOM nodes; Modifying attributes?
    primarykey
    data
    text
    <p>I've asked a few questions as of recent on this topic, and whether answered or not, I've been learning a fair amount about the tech involved. In any case;</p> <p>I've been reworking a templating engine I had created previously, moving the parsing engine from being regular expression driven, to node (XML) driven. For comparison's sake here are the two:</p> <p><strong>Regex driven:</strong></p> <pre><code>&lt;body&gt; &lt;!-- {{ region:myRegion }} --&gt; &lt;div class="myClass"&gt; &lt;h1&gt;{{ var:myHeading format:trim[200] }}&lt;/h1&gt; &lt;/div&gt; &lt;!-- {{ region:myRegion }} --&gt; &lt;/body&gt; </code></pre> <p><strong>Node driven:</strong></p> <pre><code>&lt;body&gt; &lt;zuq:region name="myRegion"&gt; &lt;div class="myClass"&gt; &lt;h1&gt; &lt;zuq:data name="myHeading"&gt; &lt;zuq:format type="trim"&gt; &lt;zuq:param name="length" value="200" /&gt; &lt;/zuq:format&gt; &lt;/zuq:data&gt; &lt;/h1&gt; &lt;/div&gt; &lt;/zuq:region&gt; &lt;/body&gt; </code></pre> <p>Now while much more verbose, I figure the node driven approach here is preferred, giving much more flexibility for situations like formatting, where multiple format nodes can be inserted and processed in order of appearance.</p> <p>Anyways, my <strong>problem</strong> lies in <strong>attributes</strong>. With the regex driven approach, if I want to have a template generated value in an attribute, it's as simple as:</p> <pre><code>&lt;a href="page.php?param={{ var:myParam }}"&gt;Link&lt;/a&gt; </code></pre> <p>I'm trying to figure out how to incorporate a clean implementation of generating attribute values, while keeping the documents well formed. Something to consider is again, the formatting options, among other possible elements that the parser would read as modifiers to data.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload