Crowdhailer

Crowdhailer

Creator of Raxx

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

Showing Posts 1 to 4

Crowdhailer

Crowdhailer OP

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 OP

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>"
Crowdhailer

Crowdhailer OP

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 OP

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

— All posts loaded —

Where Next? Top

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 15136 120
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
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
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New

Other Trending Topics Top

mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
lawik
I was thinking since Goatmire Elixir turned out pretty good I should maybe do another one. 30th of Sep - 2nd of Oct this year./ The firs...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews