" To b...">All geek questions in one placeHow to render a string as an erb file?How to edit a line as erb file rendering.For example, I want this line:"Hello <%= 'World'%>" To be: "Hello World" How can i do this?+6ruby ruby-on-rails erbOdded harth Nov 01 '11 at 14:09source share1 answerIf I understand you correctly, this will be useful: require 'erb' str = "Hello <%= 'World'%>" result = ERB.new(str).result # => "Hello World" UPDATEIf you want to use variables: require 'erb' w = "World" str = "Hello <%= w %>" result = ERB.new(str).result(binding) # => "Hello World" +18Warhog Nov 01 '11 at 14:17source shareSource: https://habr.com/ru/post/900522/More articles:Maven for static web projects - javascriptRails 3.1 - Development Using Mountable Engines - ruby-on-railsIs it possible to add any element to the context menus of the android (system menu) - androidDisable nginx logs - loggingDelete rows in a data frame based on three columns - rhow to convert an object to json using jsonconvert - without - key-qoutations - jsonAVCaptureVideoDataOutput and setting kCVPixelBufferWidthKey & kCVPixelBufferHeightKey - iosHow to make ASP tags CheckBoxList on the same line as the checkbox - cssReordering table rows through jQuery giving unwanted results in IE - javascriptAxis: CheckBox checkbox and text are not on the same line - asp.netAll Articles
How to edit a line as erb file rendering.
For example, I want this line:
"Hello <%= 'World'%>"
To be:
"Hello World"
How can i do this?
If I understand you correctly, this will be useful:
require 'erb' str = "Hello <%= 'World'%>" result = ERB.new(str).result # => "Hello World"
UPDATE
If you want to use variables:
require 'erb' w = "World" str = "Hello <%= w %>" result = ERB.new(str).result(binding) # => "Hello World"
Source: https://habr.com/ru/post/900522/More articles:Maven for static web projects - javascriptRails 3.1 - Development Using Mountable Engines - ruby-on-railsIs it possible to add any element to the context menus of the android (system menu) - androidDisable nginx logs - loggingDelete rows in a data frame based on three columns - rhow to convert an object to json using jsonconvert - without - key-qoutations - jsonAVCaptureVideoDataOutput and setting kCVPixelBufferWidthKey & kCVPixelBufferHeightKey - iosHow to make ASP tags CheckBoxList on the same line as the checkbox - cssReordering table rows through jQuery giving unwanted results in IE - javascriptAxis: CheckBox checkbox and text are not on the same line - asp.netAll Articles