I want to do something like this:
require 'erb'
@var = 'test'
template = ERB.new File.new("template.erb").read
rendered = template.result(binding())
But how can I use partials in template.erb?
I want to do something like this:
require 'erb'
@var = 'test'
template = ERB.new File.new("template.erb").read
rendered = template.result(binding())
But how can I use partials in template.erb?
Perhaps brute-force it?
Was trying to find out the same thing and didn't find much that was satisfying other than using the Tilt gem, which wraps ERB and other templating systems and supports passing blocks (aka, the results of a separate render call) which may be a little nicer.
Seen on: https://code.tutsplus.com/tutorials/ruby-for-newbies-the-tilt-gem--net-20027
layout.erb
Then in your ruby call
It will apply the results of the
other_template
into theyield
body.