GithubHelp home page GithubHelp logo

Comments (3)

Swaagie avatar Swaagie commented on May 20, 2024

Totally agree on the documentation part, will improve on that this weekend.

The issue your describing is more related to the inner workings of the htmlparser2 though. It minifies HTML, not HTML templates. The problem is that htmlparser2 will see the <> of ejs as an element, while it actually is not. Basically you want minimize to parse your compiled templates, e.g. the output <%= error %>.

As far skipping, you should be able to simply call the next callback, e.g. if (node.name === '%=') next();. While traversing the DOM each element is simply handed of to your plugins as this allows maximum flexibility.

from minimize.

voor avatar voor commented on May 20, 2024

While the next(); callback will avoid processing it further in the plugin, the end result is still an output of:

Goes in:

<%= error %>

Comes out:

<%= error="" %=""></%=>

from minimize.

Swaagie avatar Swaagie commented on May 20, 2024

This is beyond plugin scope. The dependency htmlparser2 will parse the HTML template and parses the <%= error %> as an element. As you can see in your output the last % is parsed to %="" (e.g. sparse attribute), as if it would be an HTML element which it is clearly not. Minimize should simply be called after the templates are rendered. This is even more optimal as it will also minify the generated/inserted HTML.

Closing this issue for now, allowing plugins to do something that is beyond the scope of this module does not make a lot of sense

from minimize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.