Closed danplisetsky closed 3 years ago
Potentially, but it's unlikely that many have been using Selmer's syntax verbatim in their content files. Still, it's a breaking change.
Let's put this behind a config flag and default to false then 😄
Good point.
Don't have a good name for the flag, though. 😄 Something like :parse-content?
, maybe?
:parse-content-with-selmer?
? it's a bit wordy but being more descriptive is always better
Yep, that works. I'll update the PR later this week
updated the PR and the docs: https://github.com/cryogen-project/cryogen-docs/pull/31
I'll get to the other PR once we've dealt with this one (:
A feature flag is good as people that have lot of code samples could very easily end up with selmer syntax in their posts.
@danplisetsky I got this idea, what about replacing this very concrete case of parsing with selmer with a more general and flexible solution that would allow any custom pre-processing of the content? In the same way that :extend-params-fn
and :update-article-fn
already allow some customization.
Then you could write something like
(core-compiler/compile-assets-timed
{:postprocess-article-html-fn
(fn postprocess [article params]
(update article :content selmer.parser/render params))})
And we would call it perhaps from htmlize-content
, extracting the :post or :page and passing it in as the article
(and then putting it back). For :posts
we would map it over the posts.
What do you think?
@holyjak sounds good to me. I don't have much time to work on this right now, unfortunately.
If the change you've suggested works for @lacarmen, feel free to amend this PR if you get the chance.
This feature looks interesting. Would this be usable in asciidoc or other template engines as well?
This runs after the raw markup is processed to html, before the html is written to a file. So it works for any markup. The only template engine supported by Cryogen is Selmer, I believe.
Replaced by #152
@danplisetsky could you perhaps try whether https://github.com/cryogen-project/cryogen-core/pull/152 (see also the example code in cryogen-project/cryogen-docs#39) satisfies your needs?
(cont. from #138)
Another feature that I wanted to see (which actually exists in Jekyll) is being able to template not only html but md content, too.
Scenario
I have my email in
config.edn
. I want to show it on my Contact page.Changes
This pull request adds the ability to use Selmer templating engine in content files. The scenario above is now doable:
contact.md
Breaking change?
Potentially, but it's unlikely that many have been using Selmer's syntax verbatim in their content files. Still, it's a breaking change.
Docs
Docs will require updating to reflect this new change.