Sha256: e61d444557066b365efc12f1fe9fff98e4ae6378ca8b82fa0f208f71244d99f1

Contents?: true

Size: 898 Bytes

Versions: 1

Compression:

Stored size: 898 Bytes

Contents

module Schreihals
  module Helpers
    def find_template(views, name, engine, &block)
      Array(views).each { |v| super(v, name, engine, &block) }
    end

    def partial(thing, locals = {})
      name = case thing
        when String then thing
        else thing.class.to_s.demodulize.underscore
      end

      haml :"partials/_#{name}", :locals => { name.to_sym => thing }.merge(locals)
    end

    def set_page_title(title)
      @page_title = title
    end

    def link_to(title, thing)
      haml "%a{href: '#{url_for thing}'} #{title}"
    end

    def url_for(thing, options = {})
      url = thing.respond_to?(:to_url) ? thing.to_url : thing.to_s
      url = "#{settings.blog_url}#{url}" if options[:absolute]
      url
    end

    def show_disqus?
      settings.disqus_name.present?
    end

    def production?
      settings.environment.to_sym == :production
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schreihals-0.0.3 lib/schreihals/helpers.rb