Extensionless extends, includes and imports
See original GitHub issueIs there any way to provide nunjucks with templates files extension name, so we could drop it in extends, includes and imports.
For example, Instead of
{% extends "layout.nj" %}
use
{% extends "layout" %}
I’ve heard that it’s possible to configure extension name when Nunjucks used in conjuration with Express. But what about other use cases, when Nunjucks used on it’s own, or with Grunt?
Issue Analytics
- State:
- Created 8 years ago
- Comments:21 (9 by maintainers)
Top Results From Across the Web
Extensionless extends, includes and imports · Issue #580 · pallets ...
My proposal is to make file extensions optional in extends, includes and imports. For example, Instead of. {% extends "layout.nj" %}.
Read more >Typescript eslint - Missing file extension "ts" import/extensions
I have installed eslint-plugin-import & eslint-import-resolver-typescript. And I cannot figure out why, I got that error. node.js · typescript ...
Read more >Features In-Depth | Less.js
Less extends CSS with dynamic behavior such as variables, mixins, operations and ... such as selector names, property names, URLs and @import statements....
Read more >import - JavaScript - MDN Web Docs - Mozilla
In Node, extension-less imports often refer to packages in node_modules . Certain bundlers may permit importing files without extensions; ...
Read more >Spring Boot Reference Documentation
To do so, include the appropriate spring-boot-*.jar files on your classpath. ... To import these extensionless files, you need to give Spring Boot...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1 since
.njk
is now the recommended extension, it would help adoption of it if.njk
would be automatically appended where there is no extension provided.@carljm posted in https://github.com/mozilla/nunjucks/pull/691#issuecomment-215252873:
It’s very minor thing, I agree. But it’s just somehow wrong to ask developer specify extension every single time while importing or including something when you’re clearly working in unified environment.
I think closest example here is ES2016, babel, systemjs. When you’re importing other modules, you do not specify
.js
extension, unless you really need to specify extension for some serious reason. For example, when importing non-standard for system file. In other words, not.js
one, but Sass or CSS. or image. It’s just a good design, since system arguably assumes that you by default would require specific to current environment files only, and not anything else. In some sense, it DRYing out code, by removing constantly repeating and really not useful extension.Same principle used in many other modern systems.
Option to drop extension just makes Nunjucks more unified with them.