Sha256: e9c153c70a4deda23c39893e2d53d316412970182d384e06dfb21c2c68a20f04
Contents?: true
Size: 1.49 KB
Versions: 8
Compression:
Stored size: 1.49 KB
Contents
=begin gettext/erb.rb - GetText for ERB Copyright (C) 2005,2006 Masao Mutoh You may redistribute it and/or modify it under the same license terms as Ruby. $Id: erb.rb,v 1.2 2006/02/23 14:53:59 mutoh Exp $ =end require 'erb' require 'gettext/container' module GetText # This module provides basic functions to evaluate plural ERB files(.rhtml) in a TextDomain. # You need to implement a class which includes GetText::ErbContainer. # # See simple examples below: # # require 'gettext/erb' # class SimpleContainer # include GetText::ErbContainer # # def initialize(domainname, domainpath = nil, locale = nil, charset = nil) # bindtextdomain(domainname, domainpath, locale) # end # end # # container = SimpleContainer.new("helloerb1", "locale") # puts container.eval_file("/your/erb/file.rhtml") # # This module is an example for template engines such as ERB. # You can implement another implementation easily to read gettext/erb.rb. module ErbContainer include Container # Evaluates ERB source(String) in the instance and returns the result HTML. # # * rhtml: an ERB source # * Returns: the Evaluated ERB result def eval_src(rhtml) erb = ERB.new(rhtml).src eval(erb, binding) end # Evaluates ERB file in the instance and returns the result HTML. # # * rhtml: an ERB file # * Returns: the Evaluated ERB result def eval_file(rhtmlpath) eval_src(IO.read(rhtmlpath)) end end end
Version data entries
8 entries across 8 versions & 1 rubygems