![]() |
#1 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,970
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Template: Indenting
I made a template. It works but I think I indented it wrong. Where should I put the indents?
Code:
program: if and(check_yes_no('#read', '', '1', ''), raw_field('#percentread') ==# 100, field('rating'),) then 'Yes' else field('#read') fi ![]() Last edited by ownedbycats; 03-27-2021 at 06:46 PM. |
![]() |
![]() |
![]() |
#2 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,444
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
![]() Quote:
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 Code:
program: if check_yes_no('#read', '', '1', '') && $$#percentread ==# 100 && $rating then 'Yes' else $#read fi 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. Last edited by chaley; 03-27-2021 at 07:15 PM. |
||
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,970
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Thank you.
BTW, the new multi-result template editor makes it a lot easier to figure the templates. ![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Template: Converting a search & replace into a template | ownedbycats | Library Management | 11 | 03-26-2021 04:32 AM |
Using built-in template functions in a custom template function | ilovejedd | Library Management | 4 | 01-28-2018 12:20 PM |
Indenting first line of paragraph | jimvde | Workshop | 3 | 07-22-2013 04:16 AM |