Debajit
Debajit

Reputation: 47111

Render partial EEx template in Elixir (non-Phoenix) app

I have a command-line Elixir app (this is not a Phoenix application), and I'd like to render a partial .eex template inside a template called say my_template.eex. I have code like this:

EEx.eval_file("layouts/my_template.eex", title: title, body: body)

and inside my_template.eex, I'd like to render the partial template _footer.eex.

How do I do this?

Upvotes: 2

Views: 729

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121000

Partial template is a convenient way to organize templates in Phoenix. They are still plain old good templates and since you are not using Phoenix, you basically have no difference between partials and “full” templates. Just render it as you do with my_template.eex:

<%= EEx.eval_file("_footer.eex", var: value) %>

Upvotes: 3

Related Questions