Sha256: 6c5a0986b85f0b331e6995cb97e20ad0cdead2a309fd45f4b5f87f1d3c1336a4

Contents?: true

Size: 617 Bytes

Versions: 1

Compression:

Stored size: 617 Bytes

Contents

require 'mustache'
require 'alephant/views'
require 'hashie'
require 'json'
require 'i18n'

module Alephant::Views
  class Base < Mustache
    attr_accessor :data

    def initialize(data = {})
      @data = Hashie::Mash.new data
    end

    def locale
      :en
    end

    def t(key, params = {})
      I18n.locale = locale
      prefix = /\/([^\/]+)\.mustache/.match(template_file)[1]
      params.merge! :default => key unless params[:default]
      translation = I18n.translate("#{prefix}.#{key}", params)
    end

    def self.inherited(subclass)
      ::Alephant::Views.register(subclass)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-renderer-0.0.10 lib/alephant/views/base.rb