Last active
December 20, 2015 21:08
-
-
Save lyndsysimon/6195069 to your computer and use it in GitHub Desktop.
A quick concept of a pythonic templating language based on Zen Coding, with inspiration from HAML and SASS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Template (proposed, unnamed language) | |
doctype(5) | |
html>head | |
style('my_stylesheet.css') | |
script('my_script.js') | |
title= {{ title }} | |
body>div.container | |
navbar(main_menu_links) | |
def navbar(links): | |
div.navbar>ul>li.navbar-link*?>iterlinks(main_menu_links) | |
#### Output (HTML) | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel='stylesheet' href='my_stylesheet.css' /> | |
<script src='my_script.js'></script> | |
<title>My Page Title</title> | |
</head> | |
<body> | |
<div class='container'> | |
<div class='navbar'> | |
<ul> | |
<li class='navbar-link'> | |
<a href='/'>Home</a> | |
</li> | |
<li class='navbar-link'> | |
<a href='/about'>About</a> | |
</li> | |
<li class='navbar-link'> | |
<a href='/faq'>FAQ</a> | |
</li> | |
</ul> | |
</div> | |
</div> | |
</body> | |
</html> | |
#### Context (Python) | |
title = 'My Page Title' | |
main_menu_links = ( | |
('/', 'home'), | |
('/about', 'about') | |
('/faq', 'faq') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just in case this goes somewhere, a nod to Stickyworld for their blog post The war on curly braces and angle brackets, which I found on Reddit's /r/python/ and inspired me to consider what I want in a templating language.