I used to use the if statement enclosing HTML in my php pages to repeatedly produce HTML units with similar content. Would like to know the equivalent in Python Pyramid.
eg:
<?php if($i<10): ?>
<div class=''x1>
<?php echo $i?>
</div>
<?php endif;?>
Want to do similarly in Pyramid framework in python within a chameleon .pt template file.
Currently doing this:
Post1="<div class='posts'>\n<h1 class='content-subhead'> Posted on "
Post2="</h1><!-- A single blog post --><section class='post'><header class='post-header'><h2 class='post-title'><a href='blog/"
Post3="</h2><p class='post-meta'>By Blaise M Crowly</p></header><div class='post-description'>"
Post4="</div><a href='blog/"
Post5="'>Read More </a></section></div> "
Post = ""
phazer = cur.fetchall()
for each in phazer:
Text = strip_tags(each[2])
Text = Text[:400]
Post=Post+Post1+str(each[4])+" "+str(each[5])+" "+str(each[6])+" "+str(each[7])+Post2+str(each[1])+"'> "+str(each[0])+"</a>"+Post3+str(Text)+Post4+str(each[1])+Post5
return render_to_response('blaise:templates/blog.pt',{'posts':Post},request=request)