Simplates
Simplates are a file format for server-side web programming.
Why Simplates?
Mixing code into templates leads to unmaintainable spaghetti. On the other hand, putting closely-related templates and code in completely separate subdirectories makes it painful to switch back and forth.
Simplates improve web development by bringing code and templates as close together as possible, without mixing them.
We're using simplates successfully in Aspen, the web framework behind Gratipay. We like the pattern. It works for us. Can it also work for other teams using other languages and templating systems and web frameworks? Let's find out. :-)
What Does a Simplate Look Like?
Here's an example:
import random [----] program = request.qs['program'] excitement = "!" * random.randint(1, 10) [----] text/html via stdlib_format <h1>Greetings, {program}{excitement}</h1> [----] text/plain via stdlib_format Greetings, {program}{excitement} [----] application/json via json_dump { "program": program , "excitement": excitement }
Implementations and Tools
- Aspen—a Python web framework that uses simplates with filesystem routing
- simplate.vim—simplates support for Vim
- simplate.xml—simplates support for Kate
- sublime-simplates—simplates support for Sublime Text
Similar Formats
- Markup Language 9 (ml9)—a simple markup language handling many different types of data in a single unified framework
Feedback? Questions?
Start a conversation on GitHub.