Replies: 2 comments
-
Pug filters warning about interpolation in filters
But it seems in Pug, custom filters may enable to process a variable or even create a function that will modify the processed content. |
Beta Was this translation helpful? Give feedback.
-
I am going through old Slim issues. Slim only covers embedded Markdown. Markdown processing at compile time from other sources is not supported right now. However the idea of supporting more evaluation at compile time is great. Maybe some extra syntax is needed for that, e.g., |
Beta Was this translation helpful? Give feedback.
-
There are various ways to include markdown
Having an embedded engine aka filter for markdown is nice, but it actually only allow to write markdown directly without a way to import any content from an external source that is not a file.
The issue is if you have markdown stored in a variable or from data (ex: JSON) you can't get it rendered in any way.
Examples:
From a variable (where pull_markdown_content is a function that will return markdown content, and so
myvar
will contain markdown):From data:
markdown:data.jsonfile.node.subnode.markdown_description
jsonfile.json
As the references linked above are showing a lot of people have tried to interpolation in a filter instead eg. something like that:
which can't work for the reasons we have seen above.
For static website generator there all is compiled there is no "runtime" as you compile static files and are not running a dynamic backend.
So instead if there were a way to enhance filters so they can accept an object to render too this would solve the problem.
Examples:
Current behavior (filter with markdown content block)
markdown: **Markdown** is _huge_
New additional behavior (filter with inline object)
I understand the interpolation inside a filter is a no go, but at least if there was a render some markdown content that come from a data file or a variable it would solve many headaches.
If my explanation is not clear feel free to ask questions.
workaround for slim usage in middleman
Add redcarpet (markdown renderer) in the Gemfile:
In middleman config (config.rb) add:
In the slim template:
It works but it is super heavy and unhandy.
Beta Was this translation helpful? Give feedback.
All reactions