-
Notifications
You must be signed in to change notification settings - Fork 9
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
Some template syntax we were spitballing on in IRC #44
Comments
Same for |
I pretty much agree with the request here - or at least the overall idea, if not the details. Stuff after the template language significant part currently is an error, so we certainly have room to do this. As @lizmat notes, the The conditional wrapping part is the trickier bit to fit in. The |
Do you really need the closer
|
@lizmat Well, for the |
aaah... ok, so |
I've often lamented the fact that every template language I've used has been dumbly concerned with producing a text stream and then I have to use that to produce a structured document with that.
It would be awesome to use a template language that understands that the output is structured and therefore assumes a DOM up front. Cro::WebApp::Template may well be this thing.
The first clarification to make is whether there is any meaning to this syntax:
That is, any particular special tag opening, followed by space-separated arguments, or attributes. If there is anything that fits this pattern already, this risks overloading that, thus complicating the parser. I'd like to prioritise keeping the parser regular. (If the pseudo-syntax I used here is unclear, it should hopefully make sense as I explain what we discussed.)
In the hypothetical case that the above is currently not a meaningful syntax, we think it would be useful to define it thus:
Examples!
<@items li><$_></@>
<@items? ul><@items li> ...
<$_.link^? a href="<$_.link>"><$_.text></$>
I bet people will be inspired to come up with more examples. My personal favourite is conditional wrapping, because the structured nature of HTML collides with the byte-stream blindness of most template languages when it comes to the requirement to repeat a conditional to close a wrapping tag. I hate it!
Here's the above UL example in full!
The conditional-wrap could actually have an else, which I thought of while writing the list above:
<$_.link^? a ... ! del>
- in this version, if the "menu item" has no link then it isdel
'd, normally rendered as a strikethroughOne thing I'm not sure about is the closing tag: currently I'm using the sigil like the existing
<@array>
iterator, but I don't think it clarifies what is being closed. Potentially, a combination of the sigil and the operator might be better, so you can make sure you've balanced things right, and remove the right thing when a change is made:</@?>
,</$^?>
. Actually, now I think about it, this should also work with just<.link^?>
so maybe the "name" of these tags are their operators and not their sigils, meaning they close like this</?>
</^?>
.Note that the simple iterator would still close like
</@>
because it's really just a condensing of the existing iterator syntax.Open to ideas!
The text was updated successfully, but these errors were encountered: