jsxgettext icon indicating copy to clipboard operation
jsxgettext copied to clipboard

Nunjucks inline if statement

Open ArmorDarks opened this issue 10 years ago • 5 comments

Hi

It seems that Nunjucks inline if statement causing error in parsing:

Whenever I try to parse that file https://github.com/LotusTM/Kotsu/blob/master/source/layouts/_layout.nj it throughs following error:

λ grunt abideExtract
Running "abideExtract:html" (abideExtract) task

C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\node_modules\acorn\acorn.js:321
    throw err;
          ^
SyntaxError: Unexpected token (19:11)
    at raise (C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\node_modules\acorn\acorn.js:319:15)
    at unexpected (C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\node_modules\acorn\acorn.js:1311:5)
    at semicolon (C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\node_modules\acorn\acorn.js:1298:47)
    at parseExpressionStatement (C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\node_modules\acorn\acorn.js:1736:5)
    at parseStatement (C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\node_modules\acorn\acorn.js:1525:19)
    at parseTopLevel (C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\node_modules\acorn\acorn.js:1469:18)
    at Object.exports.parse (C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\node_modules\acorn\acorn.js:47:12)
    at C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\lib\jsxgettext.js:128:27
    at Array.forEach (native)
    at parse (C:\Users\ArmorDarks\AppData\Roaming\npm\node_modules\jsxgettext\lib\jsxgettext.js:125:24)
Fatal error: Command "C:\Users\ArmorDarks\AppData\Roaming\npm\jsxgettext source/layouts/_layout.nj -o locale\templates\LC_MESSAGES\messages.pot --join-existing --language Jinja" exited with a non-zero status

It appears only if I try to run particularly this file — no issues with other.

Seems that following line causing troubles:

<title>{{ pageTitle if pageTitle else site.name }}</title>

Nunjucks is pretty close to Jinja and if I'm not wrong, that inline statement shouldn't cause any troubles for parser, but it does.

ArmorDarks avatar Feb 20 '15 08:02 ArmorDarks

@ArmorDarks - I'm not very familiar with this part of the code. Do you think you can create a patch that resolves this? I'd be more than happy to review it.

BYK avatar Mar 16 '15 20:03 BYK

Looks like #78 is the same issue.

muffinresearch avatar Mar 18 '15 10:03 muffinresearch

Thanks for reply

I'd be glad to, but, unfortunately, I'm not an JS developer :(

ArmorDarks avatar Mar 18 '15 12:03 ArmorDarks

I'd be glad to, but, unfortunately, I'm not an JS developer :(

Eh, fat chance huh? Well then we should probably wait until #82 is done.

BYK avatar Mar 18 '15 13:03 BYK

This is quite old issue, and seems that 82 doesn't move fast either because of complexity... Is there any chances to see fix for inline if at least? it's most often encountered issue in Jinja and Nunjucks templates.

ArmorDarks avatar Jun 02 '15 09:06 ArmorDarks