-
Notifications
You must be signed in to change notification settings - Fork 10
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
Request: Allow comments on macro arguments #273
Comments
Problem here is that you want to be able add a delimiter inside a delimiter, which is not allowed in the jinja syntax. I agree it would be nice to be able to add docs on arguments, but in this case, it'd make rinja not compliant with jinja. |
Yeah that is not something I did not even begin to consider. Up to you if you want to leave this up as a possibility for the future. I imagine the compatibility is something you would prefer to keep. I am inclined to believe you if you say it just isn't possible. |
If jinja officially supports adding comments inside jinja blocks, then I'm fine adding it too. Please propose it on jinja directly. |
One can always add the comments before or inside the macro: {#
Macro to generate an HTML `<input>` element.
Arguments:
* `name` [string]: that is submitted in a POST request
* `value` [string, optional]: prefilled value
#}
{% macro input(name, value = "") %}
<input name="{{ name }}" value="{{ value }}">
{% endmacro input %} {% macro input(name, value = "") %}
{#
Macro to generate an HTML `<input>` element.
Arguments:
* `name` [string]: key that is submitted in a POST request
* `value` [string, optional]: pre-filled value
#}
<input name="{{ name }}" value="{{ value }}">
{% endmacro input %} Actually, I find this much more readable than writing the comments in-between the lines. In rust you wouldn't write ↓ either: /// Function to generate an HTML `<input>` element.
fn input(
/// key that is submitted in a POST request
name: &str,
/// pre-filled value
value: Option<&str>,
) -> String {…} Actually, I don't know if this is valid code, and if so, what rustdoc would make of it. |
It's not valid code since you can't put attributes on function arguments. ;) |
Will do. Once I get around to it I will reference it back to this issue. Thank you for the consideration. |
Thanks! Waiting to hear from it then. |
I am using git main
Admittedly, this use case is derived from a somewhat degenerate pattern.
I can define this macro...
This fails to compile...
The error provided is...
error: expected
)to close macro argument list
The error correctly points to the issue.
My use case for wanting this feature is the below macro definition. I have to make a substantial amount of user forms for my project.
Why I am requesting this
Why this may not be a good feature
bon
ortyped_builder
)I would not at all be disappointed if this was rejected. If approved, I could attempt an implementation
The text was updated successfully, but these errors were encountered: