mozilla / nunjucks

A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)
https://mozilla.github.io/nunjucks/
BSD 2-Clause "Simplified" License
8.48k stars 634 forks source link

Using new line as blockEnd tag don’t work #1417

Open DevOpsCraftsman opened 1 year ago

DevOpsCraftsman commented 1 year ago

I’m trying to use a "blade" (from laravel) like syntaxe, but without success:

const nunjucks = require("nunjucks")
nunjucks.configure("", {
    tags: {
        blockStart: "@",
        blockEnd: "\n",
    }
})

nunjucks.renderString(`
@if 'a' == 'b'
  <p>Yes</p>
@endif
`)
Template render error: (unknown path) [Line 3, Column 12]
  unexpected token: /

And with:

nunjucks.renderString(`
@if 'a' == 'b'
  a
@endif
`)
Template render error: (unknown path) [Line 4, Column 1]
  expected block end in if statement

I think the parser can’t handle it properly for some reason…