Giter Club home page Giter Club logo

Comments (3)

Swaagie avatar Swaagie commented on August 20, 2024

You could use the defaults blocks of code and/or pre which will not be stripped from spaces. See, https://github.com/Moveo/minimize/blob/master/lib/list.js#L36-L39, the mentioned options only work on attributes. Let me know if this works, PR to improve the docs are always welcome :)

from minimize.

virgofx avatar virgofx commented on August 20, 2024

@Swaagie I know you've mentioned in the README.md that PHP inline templates are not supported but adding functionality that would allow for certain start/end blocks to be ignored would solve that as well.

I was thinking about trying to implement this actually and perhaps it would require up to 2 passes where you don't actually ignore certain blocks but replace them with placeholders {{$1}} as necessary prior to the current HTML minification logic and restoring the map subsequently afterwards. Would this be possible? I'm desperately trying to achieve minification of PHTML for the HTML only portion (while ignoring PHP) --- <div>Hello <?php echo 'John'; ?></div>

Would this be possible or easy to integrate?

from minimize.

Swaagie avatar Swaagie commented on August 20, 2024

Sorry for the slow response, the only proper way to implement this would be by providing a custom DOM parser. Currently the domparser of htmlparser2 is used by default. This parser confuses the <?php ?> of PHP with HTML. So parsing PHP templates would require a custom parser that understands these PHP tags. Minimize already supports custom parsers as argument of the constructor. But I think the simpler route is probably processing the templates after the PHP parser has inserted the variables and just before the content is send of the wire to the browser.

edit: as for replacing, that could be done probably as {{$1}} would be seen as text by the parser. That is outside the scope of this module though. But it is something you could probably achieve reasonably simple yourself. By simply replacing the PHP tags before the template is run through minimize.

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.