eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.47k stars 313 forks source link

for loop in pages? #170

Open fedelibre opened 9 years ago

fedelibre commented 9 years ago

I wonder if cactus allows to use a (django template) for loop inside a regular page. I don't think that Cactus has a model like in Django. Am I wrong? All I need actually is the access to paths and files in /static/images.

Purpose: reduce typing redundant html code for an image gallery. I'd like to say something like (pseudocode):

{% for file in /static/images/folder %}
    <li>
      <a href="{{full_path}}" title="{{file}}"><img src="{{full_path}}" alt="{{file}}" /></a>
    </li>
{% endfor %}
krallin commented 9 years ago

The site should be in context (if not, write a plugin to inject the site in your context), and then call site.static() to get a list of static files. If you need more complex filtering, this probably should happen in a plugin.

Cheers,

fedelibre commented 9 years ago

@krallin can you provide an example?