module Grass::Helpers::RenderHelper

Public Instance Methods

include_partial(key) click to toggle source
# File lib/grass/helpers/render_helper.rb, line 8
def include_partial key
  source = Source[key].first || init_source_if_file_exists(key)
  source.try(:raw)
end
render_content() click to toggle source
# File lib/grass/helpers/render_helper.rb, line 19
def render_content
  @data[:source].try(:render,@data)
end
render_partial(key, data = nil) click to toggle source
# File lib/grass/helpers/render_helper.rb, line 13
def render_partial key, data = nil
  data ||= @data
  source = Source[key].first || init_source_if_file_exists(key)
  source.try(:render,data)
end

Private Instance Methods

init_source_if_file_exists(key) click to toggle source
# File lib/grass/helpers/render_helper.rb, line 25
def init_source_if_file_exists key
  key = Grass::Key.new(id: key)
  return unless File.exists?(key.filepath)
  source = Grass::Source.find_or_create_by!(filepath: key.filepath)
  source.raw = File.read(source.filepath)
  source.commit!
  source
end