maizzle / framework

Quickly build HTML emails with Tailwind CSS.
https://maizzle.com
MIT License
1.24k stars 49 forks source link

PostHTML options not inherited in components #417

Closed cossssmin closed 3 years ago

cossssmin commented 3 years ago

https://stackoverflow.com/questions/66264845/inserting-ignored-php-code-within-maizzle-components

As Mark explains in the SO question, currently Components do not use options that you set in your config.js for PostHTML.

So if you had a component like this:

<!-- src/components/example.html -->

Start date in component is: <?php echo $start_date ?>

... and you configure build.posthtml.options to ignore PHP tags:

// config.js

module.exports = {
  build: {
    posthtml: {
      options: {
        directives: [{ name: '?php', start: '<', end: '>' }]
      }
    }
  }
}

... using the Component like this:

Start date in template is: <?php echo $start_date ?>

<component src="src/components/example.html"></component>

... will currently render:

Start date in template is: <?php echo $start_date ?>

Start date in component is: 

A possible solution might be for posthtml-modules to accept and use PostHTML options in its processWithPostHtml method.

cossssmin commented 3 years ago

Available in v3.1.6