Create dynamic ERB templates?
I am using ERB to generate HTML snippets. So I have a (html.erb) template that looks like this:
<html><head><title>Artsy</title></head>
<body>
<div id='name-container'>
<%= @name %>
</div>
</body>
</html>
And after rendering it looks like this:
<html><head><title>Artsy</title></head>
<body>
<div id='name-container'>
Johnny
</div>
</body>
</html>
I have several related questions:
Say that I want the user to be able to modify the ERB templates visually, so that he, for example, can move the container using id = 'name-container'
to another part of the template. What should I learn to do this?
ERB is a templating engine for Ruby and I use it because the values I have come from a Ruby application. However, if I want to explore alternatives on how to do this (having a template and being able to pass expected parameters like @name), what should I be looking for?
source to share
Custom editable erb templates are a bad idea because they are not isolated at all: a user can easily write erb with destructive side effects (either intentionally or not), or end up relying on aspects of your application that you want to change.
Use a templating language designed for this purpose, like liquid
source to share