zaach / jsxgettext

Extract gettext calls from JavaScript, EJS, and other template formats.
Mozilla Public License 2.0
105 stars 56 forks source link

Nunjucks inline if statement #83

Open ArmorDarks opened 9 years ago

ArmorDarks commented 9 years ago

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.

BYK commented 9 years ago

@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.

muffinresearch commented 9 years ago

Looks like #78 is the same issue.

ArmorDarks commented 9 years ago

Thanks for reply

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

BYK commented 9 years ago

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.

ArmorDarks commented 9 years ago

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.