Sha256: 4df040b14863cff23772ac2fc2225a9400fdf294a5aba8619b6fd1a0f7321194

Contents?: true

Size: 1.53 KB

Versions: 49

Compression:

Stored size: 1.53 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, :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

49 entries across 49 versions & 2 rubygems

Version Path
classiccms-0.3.4 vendor/bundle/gems/temple-0.4.0/lib/temple/grammar.rb
classiccms-0.3.3 vendor/bundle/gems/temple-0.4.0/lib/temple/grammar.rb
classiccms-0.3.2 vendor/bundle/gems/temple-0.4.0/lib/temple/grammar.rb
classiccms-0.3.1 vendor/bundle/gems/temple-0.4.0/lib/temple/grammar.rb
classiccms-0.3.0 vendor/bundle/gems/temple-0.4.0/lib/temple/grammar.rb
classiccms-0.2.4.pre vendor/bundle/gems/temple-0.4.0/lib/temple/grammar.rb
temple-0.4.0 lib/temple/grammar.rb
temple-0.3.5 lib/temple/grammar.rb
temple-0.3.4 lib/temple/grammar.rb