View Single Post
Old 09-14-2022, 02:03 PM   #5
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,452
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by 01100001 View Post
My code blocks were missing li tags, here's me fixing that (not that it helped my situation, but it helps keep things clear):

Code:
program:
  before = '<ul>';
  after = '</ul>';
  j = '';
  for i in 'tags':
    j += '<li>' + i + '</li>';
  rof;
  before + j + after;
Code:
program: before = '<ul>'; after = '</ul>'; j = ''; for i in 'tags': j += '<li>' + i + '</li>'; rof; before + j + after;
I have also tried using field('tags') (instead of 'tags') and strcat(before, j, after); (instead of before + j + after;) in my code. Still same error.
Probably isn't exactly the same error.

You have several problems:
  • The template language doesn't contain the += operator.
  • The string concatenation operator is & not +.
  • 'tags' is a constant string. You should use $tags, field('tags'), or raw_field('tags').
  • Semicolons are statement separators, not terminators. For example, using a semicolon before rof or fi is an error. It is an error to put one at the end of the program, but tolerated.

Here is a corrected version:
Code:
program:
  before = '<ul>';
  after = '</ul>';
  j = '';
  for i in $tags:
    j = j & '<li>' & i & '</li>'
  rof;
  before & j & after
Comment: I don't see the point of the before and after variables. Why not do
Code:
program:
  j = '';
  for i in $tags:
    j = j & '<li>' & i & '</li>'
  rof;
  '<ul>' & j & '</ul>'
chaley is offline   Reply With Quote