Touching up the docs

This commit is contained in:
Mitchell Hanberg 2019-07-03 22:05:50 -04:00
parent cf0707f8aa
commit 6c8246fe89
2 changed files with 15 additions and 5 deletions

View file

@ -1,6 +1,7 @@
# Temple
[![Build Status](https://travis-ci.com/mhanberg/temple.svg?branch=master)](https://travis-ci.com/mhanberg/temple)
[![Hex.pm](https://img.shields.io/hexpm/v/temple.svg)](https://hex.pm/packages/temple)
Temple is a DSL for writing HTML using Elixir.
@ -8,19 +9,20 @@ You're probably here because you want to use Temple to write Phoenix templates,
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `temple` to your list of dependencies in `mix.exs`:
Add `temple` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:temple, "~> 0.1.0"}
]
[{:temple, "~> 0.1.0"}]
end
```
## Usage
Using Temple is a as simple as using the DSL inside of an `htm/1` block. This returns a safe result of the form `{:safe, html_string}`.
See the [documentation](https://hexdocs.pm/temple/0.1.0/Temple.Tags.html) for more details.
```elixir
use Temple
@ -57,6 +59,8 @@ Temple provides an API for creating custom components that act as custom HTML el
These components can be given `props` that are available inside the component definition as module attributes. The contents of a components `do` block are available as a special `@children` attribute.
See the [documentation](https://hexdocs.pm/temple/0.1.0/Temple.html#defcomponent/2) for more details.
```elixir
defcomponent :flex do
div id: @id, class: "flex" do
@ -79,6 +83,8 @@ Temple provides macros for working with the helpers provided by the [Phoenix.HTM
Most of the macros are purely wrappers, while the semantics of some are changed to work with Temple.
See the [documentation](https://hexdocs.pm/temple/0.1.0/Temple.Form.html#content) for more details.
```elixir
htm do
form_for @conn, Routes.some_path(@conn, :create) do
@ -91,6 +97,8 @@ end
Add the templating engine to your Phoenix configuration.
See the [documentation](https://hexdocs.pm/temple/0.1.0/Temple.Engine.html#content) for more details.
```elixir
# config.exs
config :phoenix, :template_engines, exs: Temple.Engine

View file

@ -2,6 +2,8 @@ defmodule Temple.Tags do
@moduledoc """
The `Temple.Tags` module defines macros for all HTML5 compliant elements.
`Temple.Tags` macros must be called inside of a `Temple.htm/1` block.
## Attributes
Tags accept a keyword list of attributes to be emitted into the element's opening tag. Multi-word attribute keys written in snake_case (`data_url`) will be transformed into kebab-case (`data-url`).