Sha256: c0c441605924882fce229fdf4464e6aff56e5fc8c96d5f659e5ee00537dbd949

Contents?: true

Size: 1.65 KB

Versions: 7

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true
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, :js, 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

7 entries across 7 versions & 2 rubygems

Version Path
brakeman-6.2.2 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/grammar.rb
brakeman-6.2.2.rc1 bundle/ruby/3.3.0/gems/temple-0.10.3/lib/temple/grammar.rb
brakeman-6.2.1 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/grammar.rb
brakeman-6.2.0 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/grammar.rb
temple-0.10.3 lib/temple/grammar.rb
temple-0.10.2 lib/temple/grammar.rb
temple-0.10.1 lib/temple/grammar.rb