-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
185b4a8
commit dfe5fb5
Showing
11 changed files
with
103 additions
and
191 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ | |
__version__ = '0.2.2' | ||
|
||
from ninjadog.ninjadog import render | ||
from ninjadog.ext.jinja2 import jinja2_renderer |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"""ninjadog v0.2.2 | ||
Usage: | ||
ninjadog string [options] <string> | ||
ninjadog file [options] <file> | ||
ninjadog - [options] | ||
ninjadog -h | --help | ||
ninjadog --version | ||
Options: | ||
-h --help show help and exit | ||
-V --version show version and exit | ||
-f --file <file> the filepath to the template | ||
-p --pretty pretty print output | ||
-c --context <context> json string to be passed as context | ||
-j --with-jinja render jinja2 syntax as well as pug | ||
-v --verbose verbose output | ||
Render pug templates to html. | ||
Use "-" to read from stdin i.e. echo "h1 hello" | ninjadog - | ||
""" | ||
from docopt import docopt | ||
import sys | ||
|
||
from ninjadog import render | ||
|
||
|
||
def main(): | ||
"""Render pug template to stdout.""" | ||
args = docopt(__doc__, argv=None, version='0.2.2') | ||
|
||
if args['--file'] and args['<file>']: | ||
raise ValueError("Cannot combine --file and <file> arguments") | ||
|
||
string = sys.stdin.read() if args['-'] else args['<string>'] | ||
file = args['--file'] or args['<file>'] | ||
pretty = args['--pretty'] | ||
context = args['--context'] | ||
with_jinja = args['--with-jinja'] | ||
verbose = args['--verbose'] | ||
|
||
output = render(string=string, file=file, pretty=pretty, context=context, with_jinja=with_jinja) | ||
|
||
if verbose: | ||
print(args, file=sys.stderr, end='\n\n') | ||
|
||
print(output) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ venusian==1.1.0 | |
WebOb==1.7.2 | ||
zope.deprecation==4.2.0 | ||
zope.interface==4.4.2 | ||
docopt==0.6.2 |
This file contains 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
This file contains 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
Oops, something went wrong.