-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Append Option #2
Comments
I need this for only specific files in the templates. Specifically, I need to append to the config/routes.cr file. maybe a file naming convention? If the file name ends with a + then it will append instead of overwrite? |
I think it's a rare case. Instead of "append", how is "custom rendering" like this? class Template < Teeplate::FileTree
directory "/path/to/template"
def overwrite_file(out_file, ...)
if out_file == "config/routes.cr"
overwrite_routes out_file, ...
else
super
end
end
def overwrite_routes(out_file, ...)
# ...
end
end |
Or, tell me more details about your story if you can. |
@mosop Thanks for your response! We are using two of your libraries to build a rails like generator for Kemalyst. They have been a huge help to this project. https://github.com/TechMagister/kemalyst-generator To generate a resource, we need to inject the routes into the /config/routes.cr file. Your suggestion of overwriting the method should work fine. You are correct that this is a rare case and something we can handle in the Template class. Thanks for the suggestion. |
Thank you.
|
Here is the Here is the scaffolding to add a new resource to the I solved this problem by re-opening the Let me know if you have other suggestions on how to solve this. |
Thank you. I'll think it over. Wait for a while. |
Hi @drujensen, I added this feature into v0.3.0. It's almost the same as you want; You add a "+" sign into the head of filename and the file is written with "append mode". Try it! |
Awesome. Thanks! |
Add the ability to append to the end of a file instead of skip/overwrite it.
The text was updated successfully, but these errors were encountered: