-
Notifications
You must be signed in to change notification settings - Fork 0
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
Shorter syntax for common use cases #2
Comments
Proposal: Positional ArgumentsInclude 2 or more positional arguments which are parsed by their type.
Verdict ➕ less typing required |
Proposal: Extend File ArgumentExtend first argument with additional information about start and end of the inclusion, separate values using
Verdict ➕ conciseprobably the most concise syntax possible (for a macro) ➖ clashes with VSCode syntaxIn VSCode, ♻️ Using two distinct separators?Using another character (e.g. It would match the caption currently generated (
➡️ ➖ Seperator needs to be escaped when needed in match stringExample: A simple Wrapping those instances in Another option would be to use |
Combine line and match parametersFor a more minimal interface, the ➕ more minimal interface (less parameters for user to remember) |
Jinja macros are different from regular Python code, in that they are mainly used in files of another type (e.g. calling a Jinja macro from Markdown). Therefore, the editor cannot provide typical affordances, such as autocomplete, inline documentation, etc.:
This leads to different trade-offs when designing functions to be used primarily in a Jinja template:
Common Use Cases
include a section of another file based on lines
{{ includex("file.md", start=5, end=10) }}
vs.--8<-- "file.md:5:10"
include a section of another file based on line content
{{ includex("file.py", start_match="def foo", end_match="return ") }}
include another file as a code block with a caption
{{ includex("file.yaml", code="yaml", caption=True) }}
include another file as a code block within a collapsed admonition
??? quote "file.yaml" {{ includex("file.yaml", lang="yaml", indent=4) }}
While all of these don't look bad in their minimal form presented here, they become tedious to write fast. Also, longer and more nested files means the total length of the expression often exceeds what is deemed acceptable (80, 88 or even 100 characters).
The text was updated successfully, but these errors were encountered: