Skip to content

Instantly share code, notes, and snippets.

@skyl
Created March 2, 2012 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyl/1961812 to your computer and use it in GitHub Desktop.
Save skyl/1961812 to your computer and use it in GitHub Desktop.
Which is actually cleaner? (django templates)
{% exec %}
try:
f = durs[duration]
f.field.widget.attrs['placeholder'] = duration
print f
except KeyError:
pass
{% endexec %}
OR
{% with durs|get:duration as f %}
{% with "placeholder:"|add:duration as placeholder %}
{{ f|attr:placeholder }}
{% endwith %}
{% endwith %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment