Sha256: 891478e543c307d257657a8a310ca2c87c398f52f547091d385c606139dd2824

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 Bytes

Contents

module Tandem
  module ApplicationHelper
    def self.included(base)
      main_app_url_helpers.each do |helper|
        base.send(:define_method, helper) do |*arguments|
          arguments = [{}] if arguments.empty?
          main_app.send(helper, *arguments)
        end
      end
    end


    def render_eco_template(template, locals = {})
      @eco_templates ||= {}

      if @eco_templates[template].nil?
        template_file = File.read("#{Tandem::Engine.config.root}/app/assets/javascripts/tandem/#{template}.jst.eco")
        @eco_templates[template] = Eco.context_for(template_file)
      end

      @eco_templates[template].call("render", locals).html_safe
    end

    private
      def self.main_app_url_helpers
        ::Rails.application.routes.url_helpers.methods.select{|method| method.match(/^(?!hash\_for).*_(path|url)$/)}
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tandem-0.2.5 app/helpers/tandem/application_helper.rb
tandem-0.2.4 app/helpers/tandem/application_helper.rb
tandem-0.2.3 app/helpers/tandem/application_helper.rb