In [2]:
%pylab --no-import-all inline

from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import division
from __future__ import with_statement

from jinja2 import Template


Populating the interactive namespace from numpy and matplotlib

In [3]:
template = Template('Hello {{ name }}!')
template.render(name='John Doe')


Out[3]:
u'Hello John Doe!'

In [4]:
template=Template("""
<!DOCTYPE HTML>
<html>
<head>
<title>HexaPlant</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.poptrox.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/init.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-wide.css" />
<link rel="stylesheet" href="css/style-normal.css" />
</noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
</head>
<body>

<!-- Header -->
<header id="header">

<!-- Logo -->
<h1 id="logo"><a href="#">HexaPlant</a></h1>

<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="#intro">Intro</a></li>
<li><a href="#one">What I Do</a></li>
<li><a href="#two">Who I Am</a></li>
<li><a href="#work">My Work</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>

</header>

<!-- Intro -->
<section id="intro" class="main style1 dark fullscreen">
<div class="content container small">
<header>
<h2>Hey.</h2>
</header>
<p>Welcome to <strong>Big Picture</strong> a responsive site template designed
by <a href="http://html5up.net">HTML5 UP</a>, built on <a href="http://skeljs.org">skelJS</a>,
and released for free under the <a href="http://html5up.net/license/">Creative Commons Attribution 3.0 license</a>.</p>
<footer>
<a href="#one" class="button style2 down">More</a>
</footer>
</div>
</section>

<!-- One -->
<section id="one" class="main style2 right dark fullscreen">
<div class="content box style2">
<header>
<h2>What I Do</h2>
</header>
<p>Lorem ipsum dolor sit amet et sapien sed elementum egestas dolore condimentum. 
Fusce blandit ultrices sapien, in accumsan orci rhoncus eu. Sed sodales venenatis arcu, 
id varius justo euismod in. Curabitur egestas consectetur magna urna.</p>
</div>
<a href="#two" class="button style2 down anchored">Next</a>
</section>

<!-- Two -->
<section id="two" class="main style2 left dark fullscreen">
<div class="content box style2">
<header>
<h2>Who I Am</h2>
</header>
<p>Lorem ipsum dolor sit amet et sapien sed elementum egestas dolore condimentum. 
Fusce blandit ultrices sapien, in accumsan orci rhoncus eu. Sed sodales venenatis arcu, 
id varius justo euismod in. Curabitur egestas consectetur magna urna.</p>
</div>
<a href="#work" class="button style2 down anchored">Next</a>
</section>

<!-- Work -->
<section id="work" class="main style3 primary">
<div class="content container">
<header>
<h2>My Work</h2>
<p>Lorem ipsum dolor sit amet et sapien sed elementum egestas dolore condimentum. 
Fusce blandit ultrices sapien, in accumsan orci rhoncus eu. Sed sodales venenatis 
arcu, id varius justo euismod in. Curabitur egestas consectetur magna vitae urna.</p>
</header>

<!--
Lightbox Gallery

Powered by poptrox. Full docs here: https://github.com/n33/jquery.poptrox
-->
<div class="container small gallery">
<div class="row flush images">
<div class="6u"><a href="images/fulls/01.jpg" class="image full l"><img src="images/thumbs/01.jpg" title="The Anonymous Red" alt="" /></a></div>
<div class="6u"><a href="images/fulls/02.jpg" class="image full r"><img src="images/thumbs/02.jpg" title="Airchitecture II" alt="" /></a></div>
</div>
<div class="row flush images">
<div class="6u"><a href="images/fulls/03.jpg" class="image full l"><img src="images/thumbs/03.jpg" title="Air Lounge" alt="" /></a></div>
<div class="6u"><a href="images/fulls/04.jpg" class="image full r"><img src="images/thumbs/04.jpg" title="Carry on" alt="" /></a></div>
</div>
<div class="row flush images">
<div class="6u"><a href="images/fulls/05.jpg" class="image full l"><img src="images/thumbs/05.jpg" title="The sparkling shell" alt="" /></a></div>
<div class="6u"><a href="images/fulls/06.jpg" class="image full r"><img src="images/thumbs/06.jpg" title="Bent IX" alt="" /></a></div>
</div>
</div>

</div>
</section>

<!-- Contact -->
<section id="contact" class="main style3 secondary">
<div class="content container">
<header>
<h2>Say Hello.</h2>
<p>Lorem ipsum dolor sit amet et sapien sed elementum egestas dolore condimentum.</p>
</header>
<div class="box container small">

<!--
Contact Form

To get this working, place a script on your server to receive the form data, then
point the "action" attribute to it (eg. action="http://mydomain.tld/mail.php").
More on how it all works here: http://www.1stwebdesigner.com/tutorials/custom-php-contact-forms/
-->
<form method="post" action="#">
<div class="row half">
<div class="6u"><input type="text" name="name" placeholder="Name" /></div>
<div class="6u"><input type="text" name="email" placeholder="Email" /></div>
</div>
<div class="row half">
<div class="12u"><textarea name="message" placeholder="Message" rows="6"></textarea></div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
    <li><input type="submit" class="button" value="Send Message" /></li>
</ul>
</div>
</div>
</form>

</div>
</div>
</section>

<!-- Footer -->
<footer id="footer">

<!--
Social Icons

Use anything from here: http://fortawesome.github.io/Font-Awesome/cheatsheet/)
-->
<ul class="actions">
<li><a href="#" class="fa solo fa-twitter"><span>Twitter</span></a></li>
<li><a href="#" class="fa solo fa-facebook"><span>Facebook</span></a></li>
<li><a href="#" class="fa solo fa-google-plus"><span>Google+</span></a></li>
<li><a href="#" class="fa solo fa-dribbble"><span>Dribbble</span></a></li>
<li><a href="#" class="fa solo fa-pinterest"><span>Pinterest</span></a></li>
<li><a href="#" class="fa solo fa-instagram"><span>Instagram</span></a></li>
</ul>

<!-- Menu -->
<ul class="menu">
<li>&copy; Untitled</li>
<li>Design: <a href="http://html5up.net/">HTML5 UP</a></li>
</ul>

</footer>

</body>
</html>
""")

In [56]:
template=Template("""
<!DOCTYPE HTML>
<html>
<head>
<title>{{title}}</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.poptrox.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/init.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-wide.css" />
<link rel="stylesheet" href="css/style-normal.css" />
</noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
</head>
<body>

<!-- Header -->
<header id="header">

<!-- Logo -->
<h1 id="logo"><a href="#">{{title}}</a></h1>

<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="#intro">{{intro_nav}}</a></li>
<li><a href="#one">{{one_nav}}</a></li>
<li><a href="#two">{{two_nav}}</a></li>
<li><a href="#work">{{work_nav}}</a></li>
<li><a href="#contact">{{contact_nav}}</a></li>
</ul>
</nav>

</header>

<!-- Intro -->
<section id="intro" class="main style1 dark fullscreen">
<div class="content container small">
<header>{{intro_header}}</header>
{{intro_body}}
<footer>{{intro_footer}}</footer>
</div>
</section>

<!-- One -->
<section id="one" class="main style2 right dark fullscreen">
<div class="content box style2">
<header>{{one_header}}</header>
{{one_body}}
</div>
{{one_footer}}
</section>

<!-- Two -->
<section id="two" class="main style2 left dark fullscreen">
<div class="content box style2">
<header>{{two_header}}</header>
{{two_body}}
</div>
{{two_footer}}
</section>

<!-- Work -->
<section id="work" class="main style3 primary">
<div class="content container">
<header>{{work_header}}</header>
{{work_body}}
</div>
</section>


</body>
</html>
""")
f=open('index.html','w')
title='HexaPlant'

intro_nav='Intro'
intro_header='<h2>iHeader</h2>'
intro_body='iBody'
intro_footer='<a href="#one" class="button style2 down">More</a>'

one_nav='One'
one_header='<h2>OneHeader</h2>'
one_body='OneBody'
one_footer='<a href="#two" class="button style2 down anchored">Next</a>'

two_nav='Two'
two_header='<h2>TwoHeader</h2>'
two_body='TwoBody'
two_footer='<a href="#work" class="button style2 down anchored">Next</a>'

work_nav='Work'
work_header='<h2>WorkHeader</h2>'
work_body="""
<!--
Lightbox Gallery

Powered by poptrox. Full docs here: https://github.com/n33/jquery.poptrox
-->
<div class="container small gallery">
<div class="row flush images">
<div class="6u"><a href="images/fulls/01.jpg" class="image full l"><img src="images/thumbs/01.jpg" title="The Anonymous Red" alt="" /></a></div>
<div class="6u"><a href="images/fulls/02.jpg" class="image full r"><img src="images/thumbs/02.jpg" title="Airchitecture II" alt="" /></a></div>
</div>
<div class="row flush images">
<div class="6u"><a href="images/fulls/03.jpg" class="image full l"><img src="images/thumbs/03.jpg" title="Air Lounge" alt="" /></a></div>
<div class="6u"><a href="images/fulls/04.jpg" class="image full r"><img src="images/thumbs/04.jpg" title="Carry on" alt="" /></a></div>
</div>
<div class="row flush images">
<div class="6u"><a href="images/fulls/05.jpg" class="image full l"><img src="images/thumbs/05.jpg" title="The sparkling shell" alt="" /></a></div>
<div class="6u"><a href="images/fulls/06.jpg" class="image full r"><img src="images/thumbs/06.jpg" title="Bent IX" alt="" /></a></div>
</div>
</div>


<!-- Contact -->
<section id="contact" class="main style3 secondary">
<div class="content container">

<div class="box container small">
<header><h2>Kontakt</h2></header>

<!-- Begin MailChimp Signup Form -->
<form action="http://hexaplant.us9.list-manage.com/subscribe/post?u=e6afdc61cac19a395b41d26e6&amp;id=e4371aa913" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<form method="post" action="#">
<div class="row half">
<div class="6u"><label for="mce-EMAIL">Email Address </label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL"></div>
<div class="6u"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
    <li></li>
</ul>
</div>
</div>
</form>

</div>
</div>
</section>


</body>
</html>
"""

f.write(template.render(title=title,
                        intro_nav=intro_nav,intro_header=intro_header,intro_body=intro_body,intro_footer=intro_footer,
                        one_nav=one_nav,one_header=one_header,one_body=one_body,one_footer=one_footer,
                        two_nav=two_nav,two_header=two_header,two_body=two_body,two_footer=two_footer,
                        work_nav=work_nav,work_header=work_header,work_body=work_body
                        ))
f.close()
print('Index.html written')


Index.html written

In [ ]: