=====================

call.html

=====================

{% macro render_dialog(title, class='dialog')-%}

   <div class = "{{ class }}">

      <h2>{{title}}</h2>

      <div class = "contents">

         {{caller()}}

 

      </div>

   </div>

 {%- endmacro %}

 

 {% call render_dialog('Call Blocl') %}

     call block과 매크로 동시 사용

 {% endcall%}

 

 

 

===========

execution.py

===========

from jinja2 import Environment, FileSystemLoader

file_loader = FileSystemLoader('templates')

env = Environment(loader=file_loader)

template = env.get_template("call.html")

template.render()

print(template.render())

 

 

==============================

실행결과

==============================

+ Recent posts