Open bep opened 1 year ago
I'm not sure how these should be represented on the file system (partials/camel_case.html?)
Any reason they cannot match the file system (albeit the nesting which could be represented by a dot)
partials/camel_case.html
> p.camel_case
partials/CamelCase.html
> p.CamelCase
partials/post/camel_case
> p.post.camel_case
Any reason they cannot match the file system (albeit the nesting which could be represented by a dot)
The "dot" for nesting would be cool, but maybe a little bit tricky. I'll think about it, but you're probably right in that we can let the developer worry about the "naming problem".
OK, thinking about this for a minute. If we
p
return a map of maps (the tree) where the last entry is a double entry with the actual partial func with and without suffix.That should just work.
I think that last comment was directed at maintainers rather than users, I sure did not get it :)
In any case we did not evoke partialCached which for me is essential, and I'd love to be able to use it with this. pc.
maybe?
Of course it couldn't be used in the elegant pipe context (variant being the last argument) but I think people using it would be aware.
I wonder if we really need this suffix, if users are aware of existing reserved function... but if not too complicated it could be customized to something different for both partial
and partialCached
or disabled altogether.
partial_suffix: p
or partial_suffix: none
In any case we did not evoke partialCached which for me is essential
Well, in my head, most of the partialCached use cases have a "bigger scope" and can be added the old way. The main use I see for this is to create some simple filter functions to be used in a pipe...
Would upper case P
(for cached) be too magic?
{{ $title := .Title | emojify | P.ToUpper }}
I would hate it if we had to destroy the above by adding some "cache options".
I'm fine with P
uppercase.
/cc @jmooring opionins?
The only time I've wanted something like this was with functions (returns something), where caching was not desirable. The p/P thing seems like it might be an easy mistake to make, and even harder to track down. And I can't think of anything else like it in the API. But overall I like this.
Maybe someday we can use it with positional args as well:
{{ p.func.mul 6 7 }}
P
, pc
, pC
... I agree the first one could lead to confusion and using casing for two different functions (taking different set of arguments) is unheard of... maybe it will come back and haunt us later but I don't think we should give up on using this on partial caching. So whatever the suffix, I'll support it :)
I'm good with p.func.foo
and pc.func.foo
.
Looking at
https://discourse.gohugo.io/t/possible-to-write-custom-filter/41900
This doesn't look too bad, but having these partials referenced as strings makes the code highlighting less than beautiful.
We could even consider a shorter namespace "alias", so it would look like:
We have had similar discussions before, and they have digressed pretty quickly. The above should be possible. I see 2 issues:
partials/camel_case.html
?).