-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
[Feature Request] : Filters #60
Comments
I am +1 for this. |
It would be even better if you could register your own filters. So the plugin would come with built-in fitlters, but you could pass in a require('posthtml-expressions')({
filters: {
upper: (str) => str.toUpperCase(),
trim: (str) => str.trim(),
join: (array, separator) => array.join(separator)
}
}) |
Seems like a good feature to add ! |
@cossssmin I like this idea and approach, there is a true feeling that we are creating our own |
Glad to hear it! 😊 Now, regarding development, I haven't looked into it, and I have a feeling it'll be pretty complicated (for me, at least) to get it working with that For starters maybe we could do a <filter name="uppercase">lorem ipsum</filter> Result: LOREM IPSUM I can totally help with writing the built-in filters that it would include, I guess we could decide on what to port over from Liquid and Nunjucks? Speaking about built-in filters, these will definitely not cover all needs, so I think the |
|
Forgot about multiple filters, so this needs to be taken into account. For example:
I think the
Thoughts? |
So far vague simple <filter name="">string</filter> nested 1 <filter name=""><filter name="">string</filter></filter> nested 2 <filter name="">string<filter name="">string</filter></filter> I think the filter to the line will be better @anikethsaha @voischev What do you think ? |
Yep, I get someone could do that, but you wouldn't have to if we have both <filter name="capitalize">
<section>
<article>
<h1>article title</h1>
<p>lorem ipsum dolor sit amet</p>
</article>
</section>
</filter> Result: <section>
<article>
<h1>Article title</h1>
<p>Lorem ipsum dolor sit amet</p>
</article>
</section> I think this is also why Jinja (docs) Nunjucks (docs) have a filter block. This way, you can apply a filter not just to your own markup, but to stuff that you include with |
i think , I think we can have PoC for either or both so that we can discuss it with the implementation with just the built-in ones! |
I think both are useful, as there are situations where you can't use the tag, and vice-versa - remember the |
yes, seems like we need both ! 👍 |
let's start with the tag just for the sake of simplicity ? or with the other one ! |
Ok, let's try with tags,
<filter name="capitalize | striptags(true) | escape | nl2br">
<h1></h1>
<filter name="!escape"><p></p></filter> // ignore filter escape ?
</filter>
or <filter name="capitalize">
<filter name="striptags(true)">
<filter name="escape">
<h1></h1>
</filter>
<filter name="!capitalize"> // ignore filter capitalize
<p></p>
</filter>
</filter>
</filter>
|
My feedback:
|
Would be awesome if
posthtml-expressions
offered support for filters, like Nunjucks does.So you could do stuff like:
...or:
The text was updated successfully, but these errors were encountered: