# The basics of using SSGen # (c) theokrueger 2024 # GPL-3.0 Licensed # Intro h1: Looping with !FOREACH p: > Simple looping can be done using the !FOREACH directive. This is useful for managing complexity. --- # Example - p: 'Create loops like so:' - span: _class: two-column-grid-with-spacer yaml: - !DEF [NAMED_CODE_NAME, "input_directory/index.page"] - !DEF - NAMED_CODE_CONTENT - | \# Syntax: !FOREACH [ \# [x, y, (...), n], \# "\\\{x} \\\{y} (...) \\\{n}", \# [xval1, yval1, (...), nval1], \# [xval2, yval2, (...), nval2], \# (...), \# ] html: body: - h1: Title - !FOREACH [ [x], '<p>\\\{x}</p>' ['Content A'], ['Content B'], ] - !INCLUDE /blocks/named-code.block br: '' html: - !DEF [NAMED_CODE_NAME, "output_directory/index.html"] - !DEF - NAMED_CODE_CONTENT - | <html> <body> <h1>Title</h1> <p>Content A</p> <p>Content B</p> </body> </html> - !INCLUDE /blocks/named-code.block # Clarification - p: Obviously, this isn't that useful on its own, but all SSGen features can be used with eachother, allowing for !FOREACH to be at the heart of your templates.