Giter VIP home page Giter VIP logo

nunjucks-cli's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nunjucks-cli's Issues

output file is empty on error in watch mode

in watch mode:

when there is a parse error in the njk template, it produces empty output files
the error is not printed to the console

when i fix the error in template, it does not recover from the error

.html extension can't be used for input even in safe cases

nunjucks-cli refuses to render any files that have the .html extension to "avoid overwriting your templates". That can only happen if the the rendered files were to be written to the same folder as where the input resides. Often that is not the case, e.g. when specifying the output folder explicitly to be a different one.

env: node\r: No such file or directory

Hey,

I'd like to use nunjucks with npm. So I installed nunjucks with:
npm i -g nunjucks-cli
If I try to run nunjucks from commandline with:
nunjucks index.html or just nunjucks
I get this error:
env: node\r: No such file or directory

Has someone the same issue?

I am running on OSX 10.11.4

Includes in partials don't seem to handle variables well

I'm not able to make macros and variables work properly in partials that I include.

I have an entry file called index.tpl, this includes a module. Inside this module I want to include a macro, I declare this at the top of the page;

{% include 'macros/content-block.tpl' %}

after which I want to use it

{{ contentblock() }}

Then I get an error that contentblock is undefined or falsy. However if I include and use it on the entry file, it does seem to work. My modules all start with an underscore to prevent them from being rendered, but still watched.

Pls help :)

Macros are case sensitive

It seems I'm unable to use macro's that have camelcasing. The below doesn't work. If I change it to all lowercase ('contentblock'), it does work.

{% include 'macros/content-block.tpl' %}

{{ contentBlock() }}

The "path" argument must be of type string. Received undefined

Trying to build a simple test.njk file using npx nunjucks-cli "test.njk" but getting an error about the path argument being undefined when it's expecting a string:

npx nunjucks-cli "test.njk"

node:internal/validators:120
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:120:11)
    at resolve (node:path:1098:7)
    at Object.<anonymous> (/private/tmp/11ty-2184/node_modules/nunjucks-cli/main.js:55:18)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v17.3.1

WORKAROUND

Give it an empty -p argument:

npx nunjucks-cli "test.njk" -p ""
Rendering: test.njk

Trouble moving from Grunt to Nunjucks CLI

I've previously been using Grunt to compile my templates as part of my build process, but now I'd like to move to npm scripts. The documentation for the Nunjucks CLI is limited, and I'm having trouble figuring out how to express my grunt task in the CLI. Here is my Grunt task:

nunjucks: {
	options: {
		data: grunt.file.readJSON('template-data.json'),
		paths: ['', '../templates/']
	},
	html: {
		files: [{
			expand: true,
			cwd: 'dev/',
			src: ['*.html.njk'],
			dest: 'dev/',
			ext: '.html'
		}]
	},
	scss: {
		files: [{
			expand: true,
			cwd: 'dev/css/',
			src: ['*.scss.njk'],
			dest: 'dev/css/',
			ext: '.scss'
		}]
	}
},

How can I do the same thing with the Nunjucks CLI?

Watch is not working properly

I've been trying the watch functionality and it seems to be broken a bit. The script seems to cache the initial version of the template files when you first started them, instead of actually refreshing the contents when a change occurred.

I'm using El Capitan and Node v7.2.1

Support JavaScript (.js) context files

Same rationale as this:

It would be handy if there was a way to expose dynamic properties — like, say, the date or Node.js version — to templates. A common way of achieving this is to load files with a .js extension and operate on their default export (i.e. via module.exports). This is done by e.g. jpm and various other tools and libraries.

e.g.:

$ cat context.js
const pkg = require('./package.json')
const year = new Date().getFullYear()

module.exports = { pkg, year }

It simply doesn't load the file, even when gets its name properly

➜ nunjucks -u -p templates/*.tpl -o rendered
Error: template not found: templates/index.tpl

Files are created and if you can see from error it get's file name as it is - index.tpl, but doesn't work with that

I believe it's path issue or so, because if I wrote just a name of the file it works well, if I wrote path with / - it throws an error template not found, if I use *.html or *.tpl it throws Unexpected token < when face first html-tag

README Incorrect

The basic examples in the README don't work because the -p option is apparently required.

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.