posthtml / posthtml-modules

Modules Plugin
MIT License
84 stars 11 forks source link

Add option to forward options to posthtml-expressions plugin #78

Closed citrus closed 2 years ago

citrus commented 2 years ago

I came across a situation where I needed to use custom delimiters in my html, so I added an option to forward options to posthtml-expressions.

Available options here: https://github.com/posthtml/posthtml-expressions#options

// module: <div><i>%[ foo ]%</i><b>{{ ignored }}</b></div>
const template = `<module href="./test/module.html" locals='{"foo":"bar"}'></module>`;
const html = await posthtml().use(plugin({ 
  expressions: { 
    delimiters: ['%[', ']%'] 
  } 
})).process(actual).then(result => clean(result.html));

console.log(html)
// <div><i>bar</i><b>{{ ignored }}</b></div>
Scrum commented 2 years ago

@citrus thank you very much. Could you add a description about this to the readme.md?

citrus commented 2 years ago

@Scrum Good call out. I've added this option to the readme.

cossssmin commented 2 years ago

Thanks for this @citrus (and sorry for the delay!).

@Scrum tests pass, can you please merge and publish a new release? Thanks!

cossssmin commented 2 years ago

Actually @citrus can you please rename the posthtmlExpressionsOptions option to just expressions?

This way it's consistent with other PostHTML plugins, like posthtml-extend. Thanks!

citrus commented 2 years ago

Actually @citrus can you please rename the posthtmlExpressionsOptions option to just expressions?

This way it's consistent with other PostHTML plugins, like posthtml-extend. Thanks!

done & done!

cossssmin commented 2 years ago

Thanks, looks good to me! Let's wait for @Scrum to review and merge/release a new version 👍

citrus commented 2 years ago

Thanks, looks good to me! Let's wait for @Scrum to review and merge/release a new version 👍

Sounds good! Let me know if anything needs to be adjusted.

cossssmin commented 2 years ago

Going to merge this now, as we have more issues to attend to (#86) and we'll release a new version with those fixes included, sorry!

Scrum commented 2 years ago

@citrus @cossssmin Thanks guys, now available in version 0.9.0