Sha256: 53d418ac7367706e113d0815217a448a4d0bc010afe172cd0ab128138c3d4797
Contents?: true
Size: 1.25 KB
Versions: 5
Compression:
Stored size: 1.25 KB
Contents
require "active_support/concern" require "active_support/memoizable" require "tilt" # We need to ensure that Tilt's ERB template uses # the same output variable that Padrino's helpers expect. Tilt::ERBTemplate.default_output_variable = "@_out_buf" module Machined module Helpers module OutputHelpers extend ActiveSupport::Concern extend ActiveSupport::Memoizable # A hash of Tilt templates that support # capture blocks where the key is the name # of the template. CAPTURE_ENGINES = { "Tilt::HamlTemplate" => :haml, "Tilt::ERBTemplate" => :erb, "Tilt::ErubisTemplate" => :erubis, "Slim::Template" => :slim } protected # Attempts to return the current engine based on # the processors for this file. This is used by # Padrino's helpers to determine which type of template # engine to use when capturing blocks. def current_engine processors = environment.attributes_for(self.pathname).processors processors or return processors.each do |processor| engine = CAPTURE_ENGINES[processor.to_s] and return engine end nil end memoize :current_engine end end end
Version data entries
5 entries across 5 versions & 1 rubygems