Giter VIP home page Giter VIP logo

Comments (7)

jeremyben avatar jeremyben commented on May 28, 2024 1

Sorry for the delay.
You guys are right, I will implement in the next days a simple boolean flag to allow use of .html.

For the record, I chose to forbid the use of .html as a source, simply because I overwrote a lot of my source files during the developement of this module, and it made me precautious about it.

from nunjucks-cli.

homosaur avatar homosaur commented on May 28, 2024

This feature seems like it could be desirable under a flag, but what is your use case for it, @thijsvandien? It would seem to me like the reason to care about the extension is that your text editor is not highlighting the code correctly and that is easily configurable in your editor. Can you elaborate a bit on why you want this?

from nunjucks-cli.

darklynx avatar darklynx commented on May 28, 2024

I'm also voting for support of this feature: allow templates to have *.html extension.
Templates are HTML files with some extended syntax so, why not to let any editor immediately recognize it as HTML via extension?

My use case it npm script:

"scripts": {
  "build-html": "nunjucks *.html -p src/html/ -o dist/",
  ...
}

There is no way that problem described in warning message can happen:

To avoid overwriting your templates, do not use html as file extension

from nunjucks-cli.

darklynx avatar darklynx commented on May 28, 2024

Also the example in Nunjucks official documentation uses html extension for templates:

{% extends "parent.html" %}

{% block left %}
This is the left side!
{% endblock %}

{% block right %}
This is the right side!
{% endblock %}

from nunjucks-cli.

thijsvandien avatar thijsvandien commented on May 28, 2024

Indeed, I am not a fan of custom extensions where there are acceptable standard ones. As @darklynx said, .html is semi-offical here. Source files being overwritten is an exceptional case, the guard for which has a disproportional impact on the happy path.

from nunjucks-cli.

darklynx avatar darklynx commented on May 28, 2024

I find the idea of @homosaur is really good: add a special cli flag to allow .html extension for templates. By default for inexperienced users the tool will refuse to accept templates under .html extension, however the more experienced users may enable this possibility and they were already warned by default behavior and warning message.

from nunjucks-cli.

thijsvandien avatar thijsvandien commented on May 28, 2024

Initially I was thinking of simply comparing the input folder to the output folder and not warning if they're distinct, since nothing can happen then. Having given it some more thought, I realize it may not be that easy when relative paths get involved. There is no such thing as the input folder and the output folder. Instead, the program would have to make a list of files that are going to be read and files that are going to be written, before actually doing so, and from that determine if there are going to be conflicts. As much as I'd like to keep the API minimal, the implementation simplicity of a flag has a strong edge here, unless there are other advantages to such preprocessing (caching?).

from nunjucks-cli.

Related Issues (13)

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.