Class: BetterHtml::Tokenizer::BaseErb

Inherits:
Erubi::Engine
  • Object
show all
Defined in:
lib/better_html/tokenizer/base_erb.rb

Direct Known Subclasses

HtmlErb, JavascriptErb

Constant Summary collapse

REGEXP_WITHOUT_TRIM =
/<%(={1,2})?(.*?)()?%>([ \t]*\r?\n)?/m
STMT_TRIM_MATCHER =
/\A(-|#)?(.*?)([-=])?\z/m
EXPR_TRIM_MATCHER =
/\A(.*?)([-=])?\z/m

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ BaseErb

Returns a new instance of BaseErb.

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
# File 'lib/better_html/tokenizer/base_erb.rb', line 18

def initialize(buffer)
  raise ArgumentError,
    "first argument must be Parser::Source::Buffer" unless buffer.is_a?(::Parser::Source::Buffer)

  @buffer = buffer
  @tokens = []
  @current_position = 0
  super(buffer.source, regexp: REGEXP_WITHOUT_TRIM, trim: false)
end

Instance Attribute Details

#current_positionObject (readonly)

Returns the value of attribute current_position.



16
17
18
# File 'lib/better_html/tokenizer/base_erb.rb', line 16

def current_position
  @current_position
end

#tokensObject (readonly)

Returns the value of attribute tokens.



15
16
17
# File 'lib/better_html/tokenizer/base_erb.rb', line 15

def tokens
  @tokens
end