Sha256: 41ba33ca34174a0d7912a3ee63dc893b57dacd9ef01ee61b3428b3bbc22a135d
Contents?: true
Size: 964 Bytes
Versions: 38
Compression:
Stored size: 964 Bytes
Contents
# frozen-string-literal: true # class Roda module RodaPlugins # The inject_erb plugin allows you to inject content directly # into the template output: # # <% inject_erb("Some HTML Here") %> # # This will inject <tt>Some HTML Here</tt> into the template output, # even though the tag being used is <tt><%</tt> and not <tt><%=</tt>. # # This method can be used inside methods, such as to wrap calls to # methods that accept template blocks, to inject code before and after # the template blocks. module InjectERB def self.load_dependencies(app) app.plugin :render end module InstanceMethods # Inject into the template output for the template currently being # rendered. def inject_erb(value) instance_variable_get(render_opts[:template_opts][:outvar]) << value.to_s end end end register_plugin(:inject_erb, InjectERB) end end
Version data entries
38 entries across 38 versions & 1 rubygems