Skip to content

Implement methods to extract Ruby and HTML individually from ERB#32

Merged
marcoroth merged 33 commits intomainfrom
extract
Feb 14, 2025
Merged

Implement methods to extract Ruby and HTML individually from ERB#32
marcoroth merged 33 commits intomainfrom
extract

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Feb 14, 2025

This pull request implements methods to extract the Ruby and HTML source individually from the HTML+ERB source.

It implements the erbx_extract_ruby_to_buffer and erbx_extract_html_to_buffer functions in C and exposes them in the ruby gem via ERBX.extract_ruby and ERBX.extract_html.

ERBX.extract_ruby("<h1><% RUBY_VERSION %></h1>")
# => "       RUBY_VERSION        "
ERBX.extract_html("<h1><% RUBY_VERSION %></h1>")
# => "<h1>                  </h1>"

Maybe we should rewrite them later when we have a proper AST so we can also filter out the ERB tokens after the start tag (=, -, etc.). Or we introduce/expand the TOKEN_ERB_START to include any ERB start tag.

…xtract_from_file` and `erbx_extract_language_T``
@marcoroth marcoroth merged commit 771c57f into main Feb 14, 2025
3 checks passed
@marcoroth marcoroth deleted the extract branch February 14, 2025 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant