HamlPy
HamlPy copied to clipboard
added compact notation for dynamic attributes
In case you are using Jinja2 with HamlPy, you may be interested in more compact expressions for dynamic attributes, for example
- extends 'campaign/base.html'
- block main_content
%h1 Campaigns
%ol
- for campaign in campaigns
%li{class: "campaign"}
%a{style: "color:red", href: url_to(campaign), style:'color:green'}= campaign.title
%a{href: url_to(campaign)} Show
%a{href: url_to(campaign, "edit")} Edit
%a{href: url_to(campaign, "delete")} Delete
.well
%a{href: url('campaign.new')} New
The proposed commit allows successful compiling of such code, however, it is currently posted more for the sake of discussion than pulling to master. Please, let me know what you think.
P.S. It needs an extra requirement, the well-known codegen by Armin from 2008, which I have just submitted to pypi to simplify its usage (it is under BSD). I don't intend to change it in the future, since the original code seems working perfectly for our case. There is a new package called astor which also provides codegen, but I was not confident in it.
You may also want to look at https://github.com/barbuza/HamlPy/commit/ed13d8cc374fba96982daef19a6bdc6fc7402fba and consequent commits.