Sha256: a928790169a82239d51b8f3d8c3d97f422b87b6a7a5122ca5e0123a3a4a38026

Contents?: true

Size: 829 Bytes

Versions: 12

Compression:

Stored size: 829 Bytes

Contents

module Coprl::Presenters::WebClient::Helpers::Sinatra
  module Partials
    # Called by built in views
    def partial(template, *args)
      template = _add_underscore(template)
      template = _add_application_dir(template) unless template.start_with?("components/") || template.start_with?("body/")
      options = args.last.is_a?(Hash) ? args.pop : {}
      options.merge!(:layout => false)
      erb(:"#{template}", options)
    end

    # Called by plugins
    def render_partial(engine, template, options = {}, locals = {}, &block)
      partial(template, options)
    end

    def _add_underscore(template)
      template_array = template.to_s.split('/')
      template_array[0..-2].join('/') + "/_#{template_array[-1]}"
    end

    def _add_application_dir(template)
      "application/#{template}"
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
coprl-3.0.0.beta.12 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.11 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.10 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.9 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.8 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.7 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.6 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.5 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.4 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.3 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.2 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb
coprl-3.0.0.beta.1 lib/coprl/presenters/web_client/helpers/sinatra/partials.rb