braindeaf
Hi, there,
I’ve taken on the enviable task of porting my shoddy Rails blog to Phoenix and it’s posed some interesting challenges. I have posts written in Textile and I need to replace some syntax to convert to Markdown before converting to HTML and now I’m on my custom Pages which where written in HAML. Ok I can convert from HAML to EEx which is fine and rewrite link_to to link, etc. But now I need to evaluate that template as a string.
Can anyone point me in the right direction, I appreciate I need the @conn to give whichever function I am after to render with the right context but render seems to always want a compiled template.
Any help is very much appreciated ![]()
RobL
Trending in Discussions
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...
New
The obligatory hello world thread!
Who are you and where are you from? :stuck_out_tongue:
New
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project.
My initial shotgu...
New
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
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
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
Is there a word for the ~> symbol used in Version strings?
Do you also just call it a Squiggle Arrow™ ?!
New
Other Trending Topics
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
Latest Phoenix Threads
Chat & Discussions>Discussions
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
- #blog-post
- #phoenix_html
- #ai
- #iex
- #graphql
- #elixirconf-us
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
Can you elaborate on this? Where are the templates stored that they cannot be compiled?
josevalim
Keep in mind that all a controller does is to call render/2 on the view. And you can define that manually:
So you could do:
But of course be careful so you don’t allow someone to evaluate any file on your system. As Ben said, compiling templates is going to be the safest and most efficient.
braindeaf
Thanks for the reply both
I wasn’t very clear, my apologies. What I meant was instead of a file template I have a string. Read directly from the DB it had something like.
I’ve then converted it into something like
So now I have to eval this string so I could do something like this I think.
I realise now this is sounding ridiculous because I could just replace link_to with
And forget about using the link function, but templates must be rendered in such a way that they have access to those View functions so I guess I’m just trying to understand how this all fits together.
Cheers guys
RobL
cblavier
I have a project where I might be doing what you’re asking: rendering HTML from fragments of
eexstored in JSON files.Here is the code we’re using:
let me know if it’s helpful!
egze
Just curious, what’s an example markup that you would pass into the function?
cblavier
Something like this:
We use it for our liveview storybook: https://storybook.phenixgroupe.com