Skip to content

Make Template dir configurable, for easy templates overrides (UI engines extensions writing) #243

Description

@swilgosz

Background

I'm writing a Bulma support extension for hanami-cli. To make it possible, I need to duplicate some commands, generators and templates, most of which are ruby files that I can safely ignore. This happens, because all our generators use __dir__, to fetch the source file to generate content from.

          def template(path, context)
            require "erb"

            ERB.new(
              File.read(File.join(__dir__, "app", path)),
              trim_mode: "-"
            ).result(context.ctx)
          end

TODO

Make the __dir__ configurable, so gem authors can easly change the base_path for generators. If file does not exists, fall-back to default Hanami::CLI path.

Pros

  • Writing frontent engine support or file interpreters spport will be very easy (bulma, boostrap, or slim/haml, etc)
  • We can minimize the number of files needed to be copied and kept in sync.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions