Sha256: a7da5737324a7a267b7e31815baeb56a0f1bd3f13b213434e73e1c4612259e32

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

module Temple
  # Temple expression grammar which can be used to validate Temple expressions.
  #
  # Example:
  #   Temple::Grammar.match? [:static, 'Valid Temple Expression']
  #   Temple::Grammar.validate! [:multi, 'Invalid Temple Expression']
  #
  # See {file:EXPRESSIONS.md Expression documentation}.
  #
  # @api public
  module Grammar
    extend Mixins::GrammarDSL

    Expression <<
      # Core abstraction
      [:multi, 'Expression*']                  |
      [:static, String]                        |
      [:dynamic, String]                       |
      [:code, String]                          |
      [:capture, String, Expression]           |
      [:newline]                               |
      # Control flow abstraction
      [:if, String, Expression, 'Expression?'] |
      [:block, String, Expression]             |
      [:case, String, 'Case*']                 |
      [:cond, 'Case*']                         |
      # Escape abstraction
      [:escape, Bool, Expression]              |
      # HTML abstraction
      [:html, :doctype, String]                |
      [:html, :comment, Expression]            |
      [:html, :condcomment, String, Expression]|
      [:html, :tag, HTMLIdentifier, Expression, 'Expression?'] |
      [:html, :attrs, 'HTMLAttr*']             |
      HTMLAttr

    EmptyExp <<
      [:newline] | [:multi, 'EmptyExp*']

    HTMLAttr <<
      [:html, :attr, HTMLIdentifier, Expression]

    HTMLIdentifier <<
      Symbol | String

    Case <<
      [Condition, 'Expression*']

    Condition <<
      String | :else

    Bool <<
      true | false

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
temple-0.4.1 lib/temple/grammar.rb