Honor Jinja's block_start/end_string options#227
Open
P-Daddy wants to merge 2 commits intosyrusakbary:masterfrom
Open
Honor Jinja's block_start/end_string options#227P-Daddy wants to merge 2 commits intosyrusakbary:masterfrom
P-Daddy wants to merge 2 commits intosyrusakbary:masterfrom
Conversation
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.
4a76e8a to
eb84811
Compare
|
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. Im not sure what this does tho. Care to explain it in the Readme file? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Tests pass and my local .jade files render as expected.