yesodweb/yesod — Issue #258: Run actions and assignments in templates
Author: pbrisbin
Created: 2012-02-08 16:09:06+00:00
State: open
Labels: Feature Request, Low priority

Apologies if this was discussed before, but I think it would be super useful to run actions in templates. The equivalent (for some definition of equivalent) functionality is used constantly in rails:

```
<% items.each do |item| %>
<% var = some_thing(item) %>

<%= var %>
<% end %>
```

I would love to do something similar:

```
$forall item <- item
$assign var <- someThing var

${var}
```

I was thinking of two styles: `$let var = pureFunction` and `$assign var <- someAction` . I have no idea how feasible this is but I know it would severely cut down on a lot of two line templates I have because I need to run some action to get some value for use inside of a `$forall` loop.