Sha256: 7a299cb229dd7f810d7ed2ad4b07443745ce9eb4647c86baf49821f336dbccf7
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 module TwitterCldr module Js class Compiler def initialize(options = {}) @locales = options[:locales] || TwitterCldr.supported_locales @features = options[:features] || renderers.keys end def compile @locales.each do |locale| contents = "" @features.each do |feature| renderer_const = renderers[feature] contents << renderer_const.new(:locale => locale).render if renderer_const end bundle = TwitterCldr::Js::Renderers::Bundle.new bundle[:contents] = contents yield CoffeeScript.compile(bundle.render, :bare => true), TwitterCldr.twitter_locale(locale) if block_given? end end private def renderers @renderers ||= { :plural_rules => TwitterCldr::Js::Renderers::PluralRules::PluralRulesRenderer, :timespan => TwitterCldr::Js::Renderers::Calendars::TimespanRenderer, :datetime => TwitterCldr::Js::Renderers::Calendars::DateTimeRenderer, :numbers => TwitterCldr::Js::Renderers::Numbers::NumbersRenderer, :currencies => TwitterCldr::Js::Renderers::Shared::CurrenciesRenderer } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twitter_cldr-1.8.0 | js/lib/compiler.rb |
twitter_cldr-1.7.0 | js/lib/compiler.rb |