Closed AndiLavera closed 3 years ago
A spec has been added.
I also changed the naming scheme for arguments. Plugin authors define argument names in their config.yml.
args:
- name
- age
Then these can be accessed in liquid templates with args.name
& args.age
. Let me know what you think.
@drujensen I updated the first comment of this PR to include an explanation of all changes. Please let me know if any additional changes need to be made.
Description of the Change
Small changes to expand the functionality of plugins.
One feature allow passing arguments to liquid template files. The syntax is:
With
granite
being the single argument.I added support for auto-generating plugs. The final commit ensures the
config.yml
file is deleted after rendering. This should of made it into the previous PR.A spec has been added for all additional features.
Benefits
Plugin templates can be more dynamic. For example, my shard Mochi supports both Granite and Jennifer ORM's. Rather than having shards "mochi-granite-plugin" and "mochi-jennifer-plugin" that would be almost duplicates of each other, I can use simple
if
statements in my plugin templates.if args.orm == "granite"
Possible Drawbacks
It's possible users don't pass in the proper arguments and the template doesn't come out right.
Example Config File
I have a branch open on my authentication shard waiting for this final PR. In case anyone else wanted to take a look, here is what the config file currently supports.
We decided not to go with submodules since the crystal binary doesn't include unused code. Because of that, I wanted only my "first" module (basic authentication) to have routes and the rest are commented out. Users can uncomment what they need and delete the rest.
Routes & plugs get auto-generated and in my liquid templates, i can reference
args.orm
andargs.extension
.