dcardamo
Dynamic generation of heex for LiveView?
Hi, I’m new to Phoenix and looking for some guidance on how I can approach building an app that allows users to author their websites (blogs, pages, etc) and those pages are served by the same phoenix app.
I’d like to allow the user to write markdown and include something like Liquid tags using the Solid module. Those tags could reference LiveComponents so that their pages can have dynamic elements in them also rather than just static content. In this way I think I can make a restrictive enough syntax that would keep this secure.
The problem I’m facing is that the only solution I’ve found is to use EEx.eval_string from this old thread (How can one render a Liveview .heex file dynamically? - #12 by barkerja) which is slow.
Are there other approaches where I can let users write markdown which generates into HTML/HEEX allowing HEEX LiveComponents to be included into their pages.
Thanks for any help and suggestions.
Most Liked
LostKobrakai
You don‘t want to eval heex when it‘s time to render content. Compiling heex is not meant to be performant as it generally happens at compile time. A more reasonable approach would be compiling the template after changes and caching the result, calling that whenever you need to render content. That should bring you quite a bit closer to the perf of eex_html in your benchmark.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex










