Pass HTML file for getting all HTML content as a string into jinja2.Markup, like
content = jinja2.Markup('python/pythonIntro.html') // I know it is wrong...
Here I need to pass file name and markup all contents. How should I do?
FYI, You can use this code for find required file from you environment and also pass path of file which return all contents of file.
from jinja2 import Markup, PackageLoader, Environment
def include_file(name):
#env = jinja2.environment
return Markup(loader.get_source(env, name)[0])
loader = PackageLoader(__name__, '')
env = Environment(loader=loader)
env.globals['include_file'] = include_file
print env.get_template('templates/<file.ext>').render() # as per address of file structure