amber_render_module
Version, currently 0.1.35 versions
- 0.1.4latestJun 15, 2020
- 0.1.3not indexedJun 15, 2020
- 0.1.2not indexedJun 15, 2020
- 0.1.1not indexedJun 15, 2020
- 0.1.0not indexedJun 15, 2020
github.com/damianham/amber_render_module
Render templates and partials from the same folder as the calling controller/view so all the artifacts for a feature code can be placed in the same folder
Nothing has been indexed for 0.1.3 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
amber_render_module:
github: damianham/amber_render_module
version: ~> 0.1.3Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.3. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
amber_render_module
Amber is a web application framework written in Crystal inspired by Kemal, Rails, Phoenix and other popular application frameworks. Normally with Amber artifacts for a feature live in directories for the type of artifact, e.g.
src/controllers/post_controller.cr
src/models/post.cr
src/views/post/_form.slang
src/views/post/edit.slang
src/views/post/index.slang
src/views/post/new.slang
src/views/post/show.slang
Which is fine and dandy but with large code bases it is better to place all artifacts for a module of code that implements a feature in the same folder. E.g. for a Post module to handle blog posts
src/modules/post/_form.slang
src/modules/post/edit.slang
src/modules/post/index.slang
src/modules/post/new.slang
src/modules/post/post_controller.cr
src/modules/post/post.cr
src/modules/post/show.slang
Use this shard to add a macro to ApplicationController so you can place all of your code for a feature in a single folder in src/modules (or src/features or however you want to organise your feature modules).
Installation
Add this to your application's shard.yml:
dependencies:
amber_render_module:
github: damianham/amber_render_module
Usage
Add the following to config/application.cr:
require "amber_render_module"
require "../src/modules/**"
In controllers in src/modules/ replace render(template_filename) with render_module(template_filename). E.g.
render("index.slang") => render_module("index.slang")
In edit.slang and new.slang in src/replace render(partial) with render_module(partial)
== render(partial: "_form.slang")
becomes
== render_module(partial: "_form.slang")
By default layouts will be rendered from the normal location (src/views/layouts) but you can pass a path to render within a layout from a different location, e.g.
render_module("index.slang", layout = true, nil, path = "src/modules")
# render src/modules/post/index.slang in layout src/modules/layouts/application.slang
render_module("index.slang", layout = "post_layout.slang", nil, path = "src/modules")
# render src/modules/post/index.slang in layout src/modules/layouts/post_layout.slang
You need to add src/modules to the amber watch command so that changes to your module artifacts cause a re-compilation
amber watch -w "./config/**/*.cr" -w "./src/views/**/*.slang" -w "./src/modules/**/*.slang" -w "./src/modules/**/*.cr"
Development
TODO: create a generator for the CLI similar to scaffold to generate the module artifacts in the same folder.
Contributing
- Fork it ( https://github.com/damianham/amber_render_module/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- damianham Damian Hamill - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.3- Tagged
- Jun 15, 2020
- Commit
6eee1743765f- Indexed
- not yet
Dependents
Repository
github.com/damianham/amber_render_module
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 14, 2026
- Versions
- 5