Andrew Bullock
Andrew Bullock

Reputation: 37378

Custom ERB tag replacement

How can I get ERB to replace tags in a format other than

<%= %>

for example:

{{   }}

Thanks

Upvotes: 1

Views: 1365

Answers (2)

gabriel
gabriel

Reputation: 1807

I believe ERb also supports inline interpolated strings (#{}) in place of percent brackets, so perhaps that might better suit your needs?

Upvotes: 1

ku1ik
ku1ik

Reputation: 1938

Maybe something like this:

ERB.new(your_template.gsub("{{", "<%=").gsub("}}", "%>")).result

I don't think there is an option to tell ERB to use different tags.

But you can use liquid library which uses this curly braces syntax.

Upvotes: 1

Related Questions