I'm using python and pyramid with mako templates on displaying web content. I have html templates that are saved in a database, and now i want to display them on a web page with styles and everything(working urls and images etc.), just like a real html page would be, but fetched from the db.
Input is something like this: general styles:
.footer-content-left {
-webkit-text-size-adjust: 80%;
-ms-text-size-adjust: 80%
}
img {
height: auto;
line-height: 100%
}
h1 a:active {color:red}
h2 a:active {color:red}
and actual content:
<div style="-ms-text-size-adjust:none; -webkit-text-size-adjust:none; color:#d9fffd; font-size:12px">Awsome link
<a style="color:#d9fffd; font-weight:normal; text-decoration:none" href="%7Blink.url:link_foo">
foo.bar
</a>
</div> etc.
Templates are fetched and edited with a premailer like this:
template = DBSession.query(Template).filter(Template.id == '1').first()
template = transform(template.template) #editing the html code with premailer
return {'template': template}
html code is sent to mako template like this: ${template}
, but end result has always been just plain text, like input in above. And code in a HTML templates is working, i'm sure about that.