Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor Jinja's block_start/end_string options #227

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

P-Daddy
Copy link

@P-Daddy P-Daddy commented Nov 28, 2015

pyjade already honors Jinja's variable_start_string and variable_end_string options, but not its block_start_string and block_end_string options. I made the following changes:

  1. Add block_start_string and block_end_string fields to Compiler instance from options.
  2. Populate above options from Jinja environment.
  3. Add command-line options for (block|variable)_(start|end)_string, valid only when --compiler=jinja.
  4. Add new Compiler methods named variable and tag, which surround their argument with the variable or block start and end strings.
  5. Replace interpolations of variable_start_string and variable_end_string with calls to variable method.
  6. Replace "{%" and "%}" literals with calls to tag method.
  7. (unrelated) Fix minor grammatical error in exception text in pyjade/ext/html.py.

Tests pass and my local .jade files render as expected.

pyjade already honors Jinja's variable_start_string and variable_end_string options, but not its block_start_string and block_end_string options.  I made the following changes:

1. Add block_start_string and block_end_string fields to Compiler instance from options.
2. Populate above options from Jinja environment.
3. Add command-line options for (block|variable)_(start|end)_string, valid only when --compiler=jinja.
4. Add new Compiler methods named variable and tag, which surround their argument with the variable or block start and end strings.
5. Replace interpolations of variable_start_string and variable_end_string with calls to variable method.
6. Replace "{%" and "%}" literals with calls to tag method.
7. (unrelated) Fix minor grammatical error in exception text in pyjade/ext/html.py.

Tests pass and my local .jade files render as expected.
convert.py (called by the pyjade console script) seems to have been broken for a while.  When it initializes django, it doesn't first configure settings.  I suppose this will work if the DJANGO_SETTINGS_MODULE environment variable is set, but who does that?

In addition, I rushed through this file earlier, and made two mistakes:

 1. I tried to remove attributes from the options value returned by optparse.OptionParser.parse_args() as if they were dictionary keys.  Too much JavaScript lately.  Anyway, turns out I'm better off leaving them there.
 2. I forgot to pass the new options on to the compiler.

While fixing these, I upgraded from the deprecated optargs.OptionParser to its replacement, argparse.ArgumentParser.
@kakulukia
Copy link

Since there are no updates to pyjade and its successor recently was deleted from pypi, I took the liberty to revive it: https://github.com/kakulukia/pypugjs

Version 5.0.1 has fixed the incompatibility with recent Django versions.
I'll be happy to merge this into the next version if you resubmit the PR to my repo.

Im not sure what this does tho. Care to explain it in the Readme file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants