| Summary: | Sub template->param($var) should return the value | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Marcel de Rooy <m.de.rooy> |
| Component: | Templates | Assignee: | Bugs List <koha-bugs> |
| Status: | NEW --- | QA Contact: | Testopia <testopia> |
| Severity: | enhancement | ||
| Priority: | P5 - low | CC: | dcook, jonathan.druart, martin.renvoize, tomascohen |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | --- |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: | Version(s) released in: | ||
| Circulation function: | |||
Easier or more elegant? Going thru VARS is hacky. What is the context? Why don't you use CGI->param? :) (In reply to Jonathan Druart from comment #2) > What is the context? Why don't you use CGI->param? :) See description too. If earlier code like C4/Auth already pushed info into the template object, it would be nice to read it back later (instead of requerying etc.). Yes, we can access {VARS} but that looks like a bad practice. In such a case CGI::param might not be in the picture. (In reply to Marcel de Rooy from comment #3) > (In reply to Jonathan Druart from comment #2) > > What is the context? Why don't you use CGI->param? :) > > See description too. If earlier code like C4/Auth already pushed info into > the template object, it would be nice to read it back later (instead of > requerying etc.). Yes, we can access {VARS} but that looks like a bad > practice. > In such a case CGI::param might not be in the picture. In frameworks like Catalyst and Mojolicious, the controller has a "stash" method which provides getting/setting of values to pass to the template. I've certainly used it for both getting and setting in both frameworks. Catalyst: $c->stash->{foo} = $bar; $c->stash( { moose => 'majestic', qux => 0 } ); $c->stash( bar => 1, gorch => 2 ); # equivalent to passing a hashref Mojolicious: my $name = $c->stash('name'); $c->stash(text => "Hello $name"); https://metacpan.org/pod/Catalyst#$c-%3Estash https://docs.mojolicious.org/Mojolicious/Guides/Tutorial#Stash-and-templates https://mojolicious.io/blog/2017/12/02/day-2-the-stash/ So returning a value from $template->param() does sound reasonable. However... I thought that we were moving away from $template->param() and to $template->{VARS} in general. (Although I don't see a Coding Guideline that says that.) |
Far easier than $template->{VARS}->{singleBranchMode} would be $template->param('singleBranchMode') What do you think? It seems a simple addition?