question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extensionless extends, includes and imports

See original GitHub issue

Hello

I’m quite new to this community, thus first of all I want to thank all maintainers and contributors for such great templating language.

My proposal is to make file extensions optional in extends, includes and imports.

For example, Instead of

{% extends "layout.nj" %}

use

{% extends "layout" %}

All extensions should be preconfigurated during Environment configuration, or in Loader. If omitted in configuration, it will fall back to default (current, extension-required) behavior.

This will make importing much more intelligent and predictable, while in same time expressive and less verbose. And less typing as bonus.

For example, let’s assume we set our ext during configuration to ['.j2', '.html']

{% include 'base' %}

Will look in following order for:

  1. base
  2. base.j2
  3. base.html
{% include 'base.j2' %}

Will look in following order for:

  1. base.j2
  2. base.j2.j2
  3. base.j2.html
{% include 'base/' %}

Will look in following order for:

  1. base/index
  2. base/index.j2
  3. base/index.html

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ThiefMastercommented, May 3, 2016

I dislike this idea a lot. “Explicit is better than implicit” and considering that the file extension can control features like autoescape this is even worse.

Besides that, you could implement this easily using a custom loader if you wanted such behavior. But I’d recommend against it.

0reactions
jeffwidmancommented, May 9, 2016

I agree with @ThiefMaster, this is less explicit and opens a can of worms around potential edge cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
`auto` Configuration File - Intuit
an auto package.json property; a JSON or YAML, extension-less rc file ".autorc ... import { AutoRc } from "auto"; import { INpmConfig }...
Read more >
Extend | Enterprise Architect User Guide - Sparx Systems
Extend. A UML Extend connector between two Use Cases. Description. An Extend connector is used to indicate that an element extends the behavior...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found