Home Escape template characters for RoR generators
Reply: 0

Escape template characters for RoR generators

user1289
1#
user1289 Published in June 24, 2018, 3:26 am

I'm trying to persuade the template that tags that use a template language are not meant to be commands but as plain text.

My output file should look like this (path: app/views/projects/index.js.erb):

<%# Render list for XHR requests %>
<%= smart_listing_update :projects %>

where the :projects is a variable

I have a template, which should generate this file(path: lib/templates/haml/scaffold/template.js.erb):

<%# Render list for XHR requests %>
<%= smart_listing_update :<%= plural_table_name %> %>

I have 2 problems with this template

  1. <%# makes a comment, so the first line in output is invisible
  2. <%= smart_listing_update looks for variable, but i need to display it as a text

Could anybody help me write <%= and <%# as it looks?

With current template I'll end up with an error

/home/vagrant/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/erb.rb:896:in `eval': (erb):5: syntax error, unexpected tOP_ASGN, expecting ')' (SyntaxError) at(( smart_listing_update :<%= plural_table_name ).to_s); @o

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 1.411077 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO