Convert ERB code into Ruby before type-checking#1836
Convert ERB code into Ruby before type-checking#1836felixefelip wants to merge 4 commits intosoutaro:masterfrom
Conversation
Use class << self for private methods
fd6e3c4 to
63cbedc
Compare
|
Good idea, but I suggest making use of Additionally, ERB isn’t limited to Rails, let alone HTML.
|
|
@ParadoxV5 thanks for the review!
The ERB::Compiler looks great, I'm going to use it.
My fault, I'm used ERB only with Rails, I'm going to adjust the tests examples.
Regarding moving this to RBS, I will analyze the projects better to give an opinion. |
|
@ParadoxV5 I have not found a way to use ERB::Compiler for the proposal of this PR. Could you instruct me on how to use it, please? Alternatively, I found the Herb that almost provides the parser we need. Herb just doesn't provide a public API with Ruby code with semicolons, but I'm trying to make a contribution to doing that here. It's ok to use that? |
…ruby_before_type_checking
The documentation above expand/collapse section
That means, erb = ERB::Compiler.new nil
erb.put_cmd = erb.insert_cmd= "\n"
puts erb.compile('Got <%= process(obj) %>!').first
Assuming |
|
Thanks for the instructions @ParadoxV5! I might have misunderstood some part, but I still couldn't to handle the verbatim texts like |
) This pull request adds `semicolons`, `comments`, and `preserve_positions` options to `Herb.extract_ruby` across all language bindings (Ruby, JavaScript, Java, Rust). This was originally requested to use the extract Ruby code with semicolons in Steep/RBS, more specifically in this PR: soutaro/steep#1836. It's because we need the Ruby code with semicolons to display the static typing errors correctly. I think this functionality could also be used in others projects like Sorbet and Packwerk. Resolves #100 --------- Co-authored-by: Felipe Felix <felipe.felix@maino.com.br> Co-authored-by: Everton <e.santos081992@gmail.com> Co-authored-by: Marco Roth <marco.roth@intergga.ch>
…ruby_before_type_checking
78925c9 to
4867dce
Compare
4867dce to
4841deb
Compare
|
Hello @ParadoxV5, Sorry for the long time to update this PR. I managed the merge of the adjustment in Herb gem to make Herb compatible for this PR, as I mentioned here #1836 (comment) So I already added it on this PR in this commit: 4841deb It's okay to proceed in this way? |
ERB to Ruby code conversion is needed to type-check ERB.
Input:
Output: (replace HTML tags with whitespace)
refs: #1409