Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhanberg/temple_phoenix
Integrates Temple and Phoenix
https://github.com/mhanberg/temple_phoenix
Last synced: 2 months ago
JSON representation
Integrates Temple and Phoenix
- Host: GitHub
- URL: https://github.com/mhanberg/temple_phoenix
- Owner: mhanberg
- License: mit
- Created: 2022-04-20T03:05:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-26T14:40:56.000Z (over 1 year ago)
- Last Synced: 2024-09-19T07:50:53.198Z (3 months ago)
- Language: Elixir
- Size: 67.4 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
> **Warning**
> Phoenix 1.7 no longer uses Phoenix.View, so this package is no longer necessary.# Temple.Phoenix
[Phoenix](https://github.com/phoenixframework/phoenix) integration for [Temple](https://github.com/mhanberg/temple).
## Installation
```elixir
def deps do
[
{:temple_phoenix, "~> 0.1"}
]
end
```This package provides
- Phoenix template engine for Phoenix views and co-located LiveView templates.
## Phoenix template engine
The Temple.Phoenix.Engine module makes it possible to use Temple with Phoenix controllers and LiveViews.
To get started, you will configure Phoenix to use this module for `.exs` files and configure Temple to
use the appropriate EEx engine..```elixir
# config.exs
config :phoenix, :template_engines,
# this will work for files named like `index.html.exs`
exs: Temple.Phoenix.Engineconfig :temple,
engine: Phoenix.HTML.Engine # or Phoenix.LiveView.Engine# config/dev.exs
config :your_app, YourAppWeb.Endpoint,
live_reload: [
patterns: [
~r"lib/myapp_web/(live|views)/.*(ex|exs)$",
~r"lib/myapp_web/templates/.*(eex|exs)$"
]
]# my_app/
# lib/
# my_app/
# my_app_web/
# templates/
# posts/
# show.html.exs
# live/
# posts_live/
# show.ex
# show.html.exs
```Now you can get started by writing `exs` files in the templates directory and they will be compiled as you would expect.