Crowdhailer

Crowdhailer

Creator of Raxx

EExHTML - safely embed content into HTML

EExHTML

Extension to Embedded Elixir (EEx), that allows content to be safely embedded into HTML.

  iex> import EEx.HTML
  iex> title = "EEx Rocks!"
  iex> content = ~E"<h1><%= title %></h1>"
  %EExHTML.Safe{data: [[[[] | "<h1>"], "EEx Rocks!"] | "</h1>"]}
  iex> "#{content}"
  "<h1>EEx Rocks!</h1>"

  iex> title = "<script>"
  iex> content = ~E"<h1><%= title %></h1>"
  %EExHTML.Safe{data: [[[[] | "<h1>"], [[[] | "&lt;"], "script" | "&gt;"]] | "</h1>"]}
  iex> "#{content}"
  "<h1>&lt;script&gt;</h1>"

Works to integrate with the rest of EEx by implementing a HTML specific engine.
It is extensible for custom data types through the EExHTML.Safe protocol.
The library handles

  • Auto escaping
  • Setting JavaScript variables

Most Liked

Crowdhailer

Crowdhailer

Creator of Raxx

0.2.1 Fix encoding of JavaScript variables.

No changes to API, reasoning is as follows.

Stop using Jason.encode_to_iodata! internally as this causes ambiguity when using String.Chars protocol, it is not possible to know if integers should be encoded as numbers or chardata.

Crowdhailer

Crowdhailer

Creator of Raxx

1.0 released

Dependency on Jason is now optional and must be added to a project that wants to use safe javascript functionality

Crowdhailer

Crowdhailer

Creator of Raxx

0.1.1 released.

Minor patch to fix a superfluous quote mark entered into pages when using the javascript_variables function.

Crowdhailer

Crowdhailer

Creator of Raxx

0.2.0 released

HTML content in lists is now correctly marked as safe, e.g.

<%= for _ <- 1..1 do %><p><%= bar %></p><% end %>
|> EEx.eval_string(bar: "<script>")
|> String.Chars.to_string()
"<p>&lt;script&gt;</p>"

Where Next?

Popular in Libraries Top

mhanberg
I just released the first version of Temple: an HTML DSL for Elixir and Phoenix! You can read this blog post or the docs for more info...
New
seancribbs
Today I released a new dialyzer Mix task as the dialyzex package! At the time we started writing this task, the existing dialyzer integra...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
pkrawat1
Presenting Aviacommerce, open source e-commerce platform in Elixir Aviacommerce is an open source e-commerce platform in Elixir. We at...
New
wfgilman
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
ostinelli
Let’s write a database! Well not really, but I think it’s a little sad that there doesn’t seem to be a simple in-memory distributed KV da...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

Sub Categories:

We're in Beta

About us Mission Statement