Using EEx.eval_string with HEEx Engine on live_view 0.18.18

Can you describe more about your use case? It’s usually a bad idea to do string eval as it’s super slow, but this will work if you truly need it:

template = """
<h1><%= @test %></h1>
"""
options = [
  engine: Phoenix.LiveView.TagEngine,
  file: __ENV__.file,
  line: __ENV__.line + 1,
  caller: __ENV__,
  indentation: 0,
  source: template,
  tag_handler: Phoenix.LiveView.HTMLEngine
]
    
template
|> EEx.eval_string([assigns: %{test: "test"}], options)
|> Phoenix.HTML.html_escape()
|> Phoenix.HTML.safe_to_string()

# "<h1>test</h1>"
2 Likes