0 votes
1 view
in Python by (11.8k points)
I utilize grunt with Pug (Jade) to deliver my HTML layouts. I need to consolidate Jinja2 syntax in my Pug records however when I run grunt to assemble the HTML documents it comes up fails since it doesn't perceive the Jinja2 language structure.

Does anybody know an answer to this?

1 Answer

0 votes
by (24.6k points)

Seems like it supports jinja2:

jinja_env = Environment(extensions=['pypugjs.ext.jinja.PyPugJSExtension'])

Look at the below pug (jade) code example:

!!! 5



    title= pageTitle


      if (foo) {




    h1.title PugJS - node template engine


      if youAreUsingPugJS

        p You are amazing


        p Get on it!

Converts into

<!DOCTYPE html>

<html lang="en">



    <script type='text/javascript'>

      if (foo) {






    <h1 class="title">PugJS - node template engine</h1>

    <div id="container">

      {%if youAreUsingPugJS%}

        <p>You are amazing</p>


        <p>Get on it!</p>





You can also utilize the utility command:

pypugjs -c jinja input.pug output.html

Wanna become a Python expert? Come and join the python certification course and get certified.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !