Mason comes with some built-in filters that can be used to process portions of content in a component.
The standard way to invoke a filter is in a block:
but filters can appear also inside a <% %> tag:
More details can be found at the official Mason::Manual::Filters page.
Here’s how to create a custom filter:
I wanted to use a custom filter that converts Markdown text to HTML, so I installed the Text::Multimarkdown
module and I created a filter like this:
which I put in lib/MyApp directory. Then I tried it in a index.mc page:
another way using the block invocation syntax:
one more way is to use a Base component, telling to process all inner components with Markdown:
then your page can contain just Markdown syntax, here’s an index.mc example page (an empy line at the beginning seems to be needed here):