question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use PyPugJs from Python without a Framework?

See original GitHub issue
  • pypugjs version: 5.8.1
  • Django version: –
  • Python version: 3.3.7
  • Operating System: MacOs 10.14.4

Description

I don’t want to install Jinja2 etc. Can i Just use PyPugJS -> HTML with variables interpolation?

What I Did

...
html=f.read()

pageTitle = 'TTTTTTTTT'
print(pypugjs.ext.html.process_pugjs (html ))   

expected output:

<title>TTTTTTTTT</title>

but i got:

<title>None</title>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
char101commented, Apr 28, 2020

I put it there so that the 3rd person could copy paste it 😉

1reaction
char101commented, Apr 28, 2020

It is possible

def compile_pug(template, vars, **options):
    parser = pypugjs.parser.Parser(template)
    block = parser.parse()
    compiler = pypugjs.ext.html.Compiler(block, pretty=True, **options)
    compiler.global_context = vars
    return compiler.compile()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Program web applications in python without a framework?
Try writing your own version of mod_php "from scratch" and see all the things PHP is doing for you automagically. The point of...
Read more >
pypugjs · PyPI
PyPugJS is a high performance port of PugJS for python, that converts any .pug ... Any templates with other extensions will not be...
Read more >
Day 25 - A Python Web App without a Framework - YouTube
Day 25 - A Python Web App without a Framework In 30 Days of Python, ... What you can do with Python is...
Read more >
Building a barebone Web API service in Python without a web ...
A barebone web API service, powered by gunicorn, that uses query paramenters to modify an in-memory data. CAVEAT: The application may sometimes ...
Read more >
Python pug to html, Pypugjs, Jinja2 tutorial PDF, Django pug ...
The core of the library consists of just a few lines of Python, using pypugjs to parse Pug templates, optionally including stylesheets from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found