KarlHeitmann / KarlHeitmann/rg_wrapper

Feature to find partials with keywords on a rails application.

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

This feature is related to #8 . And is blocked by #3

In the views of a Rails application, you usually render other files inside a layout, these files are called "partials".

Sometimes you need to search a keyword that is displayed on the browser, and you need to find where this keyword is in the source code. You can grep your codebase to find it. But what if the place where is the keyword is a partial file? The partial file can be rendered inside any other view file.

In Rails, partial files starts with underscore, and have extension `.html.erb`. eg `app/views/_mypartialfile.html.erb`. The ruby instruction to render this partial is: `<%= render partial: 'mypartialfile', locals: {foo: bar} %>`. So one regex that can match the pattern `render...mypartialfile` can be: `render.*mypartialfile`

This feature for consists in these steps:

1. Do the search
2. if the match is inside a file that starts with underscore and ends with `.html.erb` extension, do another search with ripgrep. This new search will be: `rg 'render.*name_file_matched_without_underscore_without_extension'`.
3. Present results to user.

The idea of this feature, is to first search a keyword on the codebase, if there are any matches inside rails partial files, take the name of the file, and find which files are rendering the partial that contains the keyword. This way around, using ruby on rails convention over configuration, you can easily see which route you will visit on the browser, and you will see the keyword you were searching for.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.