Sha256: d38cf99dba727e1c644f3804ef82eccf5f54c89dd7bb30a95e32a98632dbd124

Contents?: true

Size: 863 Bytes

Versions: 4

Compression:

Stored size: 863 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 = nil 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

4 entries across 4 versions & 1 rubygems

Version Path
tandem-0.2.2 app/helpers/tandem/application_helper.rb
tandem-0.2.1 app/helpers/tandem/application_helper.rb
tandem-0.2.0 app/helpers/tandem/application_helper.rb
tandem-0.2.0.rc app/helpers/tandem/application_helper.rb