https://github.com/lawfulgood/simplates
https://github.com/lawfulgood/simplates
elixir templates
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/lawfulgood/simplates
- Owner: LawfulGood
- License: mit
- Created: 2017-02-11T15:01:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-05T00:25:11.000Z (over 8 years ago)
- Last Synced: 2025-01-18T10:20:43.382Z (over 1 year ago)
- Topics: elixir, templates
- Language: Elixir
- Size: 31.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Simplates for Elixir
[](https://travis-ci.org/LawfulGood/simplates)
[](https://coveralls.io/github/LawfulGood/simplates?branch=master)
Simplates are a file format for server-side web programming. Used currently in [Infuse](https://github.com/LawfulGood/infuse).
This repository is my future spec for [simplates.org](http://simplates.org/)
## 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.
## What does a Simplate look like?
Here's an example:
```
program = "hellö"
excitement = :rand.uniform(100)
<%= hello %>, program, my favorite number is <%= num %>
```
## Installation
1. Add `simplates` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:simplates, "~> 0.4.0"}]
end
```
2. Ensure `simplates` is started before your application:
```elixir
def application do
[applications: [:simplates]]
end
```
3. Create & render like so
```elixir
page = Simplates.Simplate.create_from_string("\nHello\n")
{output, _} = Simplates.Simplate.render(page, "text/plain")
```