omg.lol
omg.lol copied to clipboard
Add support for simple conditional logic in weblog templates
E.g.
[if {image}]
<div class="hero-image">
<img src="{image}">
</div>
[fi]
This has been stewing in my mind all night, and I'm wondering if it would make any sense to sort of split this apart into different bits.
Like, for example, right now you've got various curly-tags (I don't know what you're calling things like {post-list}
) whose HTML output is defined in the configuration file. What if you did part of this via that route, by letting people define custom curly-tags in configuration.
So, e.g., someone might have
Curly-tag: {meta-image}
Meta image format: <<[<meta property="og:image" content="$image">]>>
(I don't know that this would be a $
variable, since you're using those for other sorts of things, but I just needed to put something here.)
then in their template they'd have
{meta-image}
and in their post front matter would have
Image: https://example.com/image.png
And then the conditional would be applied based on whether or not that $image
is defined in the front matter; if not, the HTML simply wouldn't be output for that post.
I read this thought now and wonder if this actually just way overcomplicates the issue, but I think my brain "worried" about having some template HTML snippets defined in the configuration file and then other HTML snippets defined in the template file, and whether or not there was some way to conform things.
I guess none of that approach would work if someone wanted on the fly to have a post that had an Image1 and and Image2 in their front matter. I think I'm just slightly concerned about growing like four or five different kinds of ways to define bits of HTML output?
Maybe I should just go to bed instead of thinking out loud on GitHub.