Skip to content

Add --template-engine option to hanami new#390

Merged
katafrakt merged 3 commits intomainfrom
cli-opt-template-engine
Mar 3, 2026
Merged

Add --template-engine option to hanami new#390
katafrakt merged 3 commits intomainfrom
cli-opt-template-engine

Conversation

@katafrakt
Copy link
Copy Markdown
Contributor

Follow up to #389. Now you can pass --template-engine option to hanami new and it will be respected.

This option takes "erb", "haml" or "slim" and:

  • Adds a gem entry to Gemfile, if not erb
  • Sets default_template_engine in config/app.rb
  • Creates the app layout with the selected template engine

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 28, 2026

ℹ️ Optional job failed: Ruby jruby

@katafrakt katafrakt force-pushed the cli-opt-template-engine branch 2 times, most recently from f930060 to 73d7041 Compare February 28, 2026 23:45
This option takes "erb", "haml" or "slim" and:
- Adds a gem entry to Gemfile, if not erb
- Sets default_template_engine in config/app.rb
- Creates the app layout with the selected template engine
@katafrakt katafrakt force-pushed the cli-opt-template-engine branch from 73d7041 to 1a73aed Compare March 1, 2026 07:57
@katafrakt katafrakt changed the title Add --template-engine cli option Add --template-engine option to hanami new Mar 1, 2026
Copy link
Copy Markdown
Member

@timriley timriley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Just left you a couple notes about things that might be good to change. Keen for your feedback.


module <%= camelized_app_name %>
class App < Hanami::App
<%- if template_engine != "erb" -%>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make this (and probably all similar output changes in this PR) conditional on --skip-view not being given.

(In other words, if --skip-view is passed, we should just ignore the --template-engine option)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a good point, thanks! I was wondering if we should warned the user that they are using a combination of options that does not make sense, but perhaps this is just obvious and there's no point in that. What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now we can just handle it internally. If --skip-view is given, it can "win" and we can just ignore any other view related flags.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. So are we good to go here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these files technically be called app_layout.haml.erb (yo dawg, I heard you like template engines)

At least this would signify that we're using templating inside them, and would make it consistent with our other .erb templates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a good point 👍

@katafrakt katafrakt force-pushed the cli-opt-template-engine branch from fb896cd to e783287 Compare March 2, 2026 20:38
@katafrakt katafrakt merged commit e16e60a into main Mar 3, 2026
13 checks passed
@katafrakt katafrakt deleted the cli-opt-template-engine branch March 3, 2026 20:07
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.

2 participants