Quote:
Originally Posted by ownedbycats
I made a template. It works but I think I indented it wrong. Where should I put the indents?
|
Wherever you want to.
Quote:
Code:
program:
if
and(check_yes_no('#read', '', '1', ''),
raw_field('#percentread') ==# 100,
field('rating'),)
then 'Yes'
else field('#read')
fi
(Context: In FanFicFare, I have it set #read to 'no' when updating a fanfic. But this also runs when I am using 'update metadata' on previously-read fanfics. This just sets it back to yes.)
|
My first answer was serious. You indent however it makes sense for you. Really.
I would indent your template differently because of what makes sense for *me*. I try to put 'things' that are syntactically at the same level at the same indent. What is 'syntactically at the same level'? Whatever I want it to be.
This is how I would indent your template.
Code:
program:
if
and(
check_yes_no('#read', '', '1', ''),
raw_field('#percentread') ==# 100,
field('rating')
)
then
'Yes'
else
field('#read')
fi
Using the new operators & field syntax I would write
Code:
program:
if check_yes_no('#read', '', '1', '') &&
$$#percentread ==# 100 &&
$rating
then
'Yes'
else
$#read
fi
It looks like this screen capture in the template tester I am currently working on.
Edit: "Break on print" is my first stab at putting breakpoints into the template tester. If you check the box then the template is evaluated only when you click "Go" (mouse or keyboard). In this case if the template processor encounters a "print" then it pauses evaluation and opens a dialog showing you the arguments of the print and all the local variables. You can click "Go" to continue evaluating the template or "Stop" to cancel evaluation. My goal is to permit "breaks" at line numbers but I haven't yet figured out how to that.