KP123

KP123

Question is pretty self explanatory. Temple is a view template library that feels like a more natural way to build markup in Elixir

Showing Posts 1 to 10

mhanberg

mhanberg

Expert LSP Core Team

I do, but I am the author of the library :sweat_smile:.

KP123

KP123 OP

Can you note any major shocks someone coming from heex should expect when using Temple? How do the Javascript blocks work with %JS{} functions?

mhanberg

mhanberg

Expert LSP Core Team

Nothing that I can think of.

One note tho is the attr and slot dsl do not work (the functions you put above a component).

mhanberg

mhanberg

Expert LSP Core Team

These actually do work.

I don’t know if they’ve always worked or if something changed that made them work, but I’m pretty sure they work as of now.

jam

jam

Looks really nice!

Is there more info on the script macro? Does it have any knowledge of the component it’s in or is it just JS?

Any plans for adding a style macro for scoped css?

mhanberg

mhanberg

Expert LSP Core Team

The tags are not actually macros, the temple macro traverses the ast inside it and compiles it using whatever EEx engine you have configured.

The script and style tags are just plain html tags, no special behavior.

I don’t have any plans regarding that, but you could probably define your own macro to do special compile time things if you wanted.

jberling

jberling

I didn’t know of this library. Just tried it out and it seems to work really nice! Thank you @mhanberg.

I’m all in for using an embedded language for these things, and implemented one for F# a looooong time ago: https://codeplexarchive.org/codeplex/project/wingbeats.

olivermt

olivermt

Whats the upside of this over html templating? If someone has a sales pitch

mhanberg

mhanberg

Expert LSP Core Team
  1. Vibes. You like how it looks and it’s easier to type. So, subjective DX I suppose.
  2. In an earlier iteration, Temple had components but EEx did not. As LiveView matured, HEEx was introduced with components, so not a huge selling point now anymore. But Temple uses the same component model, so components can be used in either markup regardless how they were authored.
  3. You can use temple and its components without LiveView, and with any EEx engine.
jberling

jberling

In a language like Elixir where everything is expressions, it works really well to embed a little language that can easily be translated to HTML. One upside is that you can use Elixir’s control flows directly without escaping the template or relying on the template’s control flows.

I listened to an interview with Chris Lattner (the father of Swift), in which he said he regrets adding statements to Swift. Because of this, they had to add a lot of extra complexity on top of Swift to support Swift UI, where you can write view hierarchies directly in Swift.

I just tried Temple and I liked how easily it could co-work with existing HEEX templates. If you are curious you could try it out, perhaps in a messy view with logic, to see if you like it. Remember, Apple put a lot of effort into supporting something similar, so if it’s a new idea for you, it’s at least worth trying.

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews