method
find_offset
v7.2.3 -
Show latest stable
- Class:
ActionView::Template::Handlers::ERB
find_offset(compiled, source_tokens, error_column)private
Find which token in the source template spans the byte range that contains the error_column, then return the offset compared to the original source template.
Iterate consecutive pairs of CODE or TEXT tokens, requiring a match of the first token before matching either token.
For example, if we want to find tokens A, B, C, we do the following:
-
Find a match for A: test error_column or advance scanner.
-
Find a match for B or A:
a. If B: start over with next token set (B, C). b. If A: test error_column or advance scanner. c. Otherwise: Advance 1 byte
Prioritize matching the next token over the current token once a match for the current token has been found. This is to prevent the current token from looping past the next token if they both match (i.e. if the current token is a single space character).