posthtml / posthtml-expressions

Use variables, JS-like expressions, and even markup-powered logic in your HTML.
Other
123 stars 20 forks source link

[fix]: Expressions doesn't work with `posthtml-extend` #53

Closed mikestopcontinues closed 6 years ago

mikestopcontinues commented 6 years ago

Problem

posthtml-extend updates the tree to be contained within the extended page. For some reason, this breaks posthtml-expressions. But it would be awesome to both use the plugins together, as well as use expressions logic in the extended template.

Reproduction

Two different issues:

  1. Try to use expressions within a template that extends another.
  2. Try to use expressions within a template that is extended by another.

Expressions work so long as you don't try to extend the current template.

Scrum commented 6 years ago

@mikestopcontinues Hi, thanks for your feedback, I'll check it out soon.

Scrum commented 6 years ago

@mikestopcontinues wait merge and publish PR

mikestopcontinues commented 6 years ago

Thanks, @GitScrum! You rock!

michael-ciniawsky commented 6 years ago

@mikestopcontinues Can you show your current posthtml config and the plugin order ?

mikestopcontinues commented 6 years ago

Sure!

posthtml([
  extend({root}),
  modules({root}),
  include({root}),
  expressions(),
]);
Scrum commented 6 years ago

Now you need set extend options plugins when call expressions

posthtml([
  extend({root, plugins: [expressions()]}),
  modules({root}),
  include({root}),
  expressions(),
]);
mikestopcontinues commented 6 years ago

Ok, thanks!

Scrum commented 6 years ago

@mikestopcontinues wait publish in npm )

michael-ciniawsky commented 6 years ago

Does posthtml-extend (not too familiar with it 😛 ) not also extend the tree (AST), so posthtml-expressions should normally work if it is used after posthtml-extend ? We use a custom walk {Function} in posthtml-expressions atm, maybe there is something lost during interpolation ?

Scrum commented 6 years ago

@mikestopcontinues Done! enjoy, and close this issue if all good.

mikestopcontinues commented 6 years ago

Thanks!