dcardamo
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.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
D4no0
How slow? This is more or less what phoenix uses to render templates too.
You could also look at EEx.compile_string/2, but that option is more for static templates as you cannot modify the template once you compiled it, only evaluate it with different assigns.
dcardamo
I did some benchmarking to see how much slower eval_string would be. Here is the code that used mdex, solid, benchee.
It’s a simple output for the eex_html and eex_eval_string examples. eval_string seems to be 1507x slower than ~H. Maybe its still good enough since its ~167 us average per call.
Results are:
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.