View Single Post
Old 01-06-2022, 10:39 PM   #270
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,369
Karma: 79528341
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Is it possible to set variables outside of the stored template?

Context: I am making this template meant for use in the column colouring.

Code:
program:

## date = $#datecol;
now = format_date(today(), 'yyyy-MM-dd');

		if days_between(date, now) <= '1' then '#aaaaa'
		elif days_between(date, now) <= '3' then '#bbbbb'
		elif days_between(date, now) <= '7' then '#ccccc' 
		fi
(though it's not quite working as expected - getting #aaaa for everything )

Note that the date variable is commented out -- I tried saving it as a stored template, colours_days_between. then this in the template tester:

Code:
program:
date = $#fanficupdated;

	colours_daysbetween()
It told me 'date' wasn't found.

I noticed this

Quote:
template(x) – evaluates x as a template. The evaluation is done in its own context, meaning that variables are not shared between the caller and the template evaluation.
so I'm thinking I'm doing this wrong but I'm not sure how to pass variables to the template - I noticed eval, but not sure if that's right.

Last edited by ownedbycats; 01-06-2022 at 11:27 PM.
ownedbycats is offline   Reply With Quote