Sha256: e03d05ecb93cd21b6c89d7019b724ca7f80c58f2d38a2e730b37edfd534bb0ef

Contents?: true

Size: 523 Bytes

Versions: 8

Compression:

Stored size: 523 Bytes

Contents

module Pione
  module Util
    module EmbededExprExpander
      # Expand embeded expressions in the string.
      def self.expand(env, str)
        return nil if str.nil?

        # parse and transform
        str.gsub(/\{(\$.+?)\}|\<\?\s*(.+?)\s*\?>/) do
          tree = Lang::DocumentParser.new.expr.parse($1 || $2)
          expr = Lang::DocumentTransformer.new.apply(tree, {package_name: nil, filename: nil})
          expr.eval(env).call_pione_method(env, "textize", []).value
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pione-0.5.0 lib/pione/util/embeded-expr-expander.rb
pione-0.5.0.alpha.2 lib/pione/util/embeded-expr-expander.rb
pione-0.5.0.alpha.1 lib/pione/util/embeded-expr-expander.rb
pione-0.4.2 lib/pione/util/embeded-expr-expander.rb
pione-0.4.1 lib/pione/util/embeded-expr-expander.rb
pione-0.4.0 lib/pione/util/embeded-expr-expander.rb
pione-0.3.2 lib/pione/util/embeded-expr-expander.rb
pione-0.3.1 lib/pione/util/embeded-expr-expander.rb