Minute HTML control in iRev

Sivakatirswami katir at hindu.org
Tue Nov 3 22:09:45 EST 2009


I have an interest in dynamically changing html code chunks based on 
conditionals

This iFrame posted on a Word Press Blog will rotate the background on 
each refresh.
But I want to take it one step further... if the definition is longer 
than 350 chars, then we
want to insert an image into the html

http://himalayanacademy.com/blog/taka/2009/11/02/words-to-ponder/

All this works beautifully, in fact it is so "light years" ahead of 
where we have been with revCGI in the past... its inspiring.

But I sometimes ask for cheese from the moon, so here goes:

 I am wondering if there is an easier way to get iRev to decide to use a 
particular chunk of html where we don't have to actually build the html 
strings inside our iRev code... but instead have irev use or not use 
sections on the page in their "natural" html form.

This works:

<?rev
[ some functions here, if you want to see them let me know I will post...]
?>

<body style="background-image: 
url(/resources/lexicon/images/backgrounds/<?rev put tBackground ?>); 
background-repeat: repeat;">
<?rev
if len(tDefinition) > 350 then
put format ("<div style=\"margin: 15px;padding:2px 15px 2px 15px;\">")
 put format ("<img 
src=\"http://www.himalayanacademy.com/resources/lexicon/images/backgrounds/EyeGlass.jpg\" 
style=\"float:left; margin-right:12px;\" />")
else
put format ("<div style=\"margin: 15px;background-color: 
#FFFFFF;padding:2px 15px 2px 15px;opacity: 0.90\">")
end if
?><h1 style="margin-top:0;text-shadow: +10% +10% 10% 
rgb(153,153,153);"><?rev put tWord ?>:</h1>
<p style:"font-size: 115%;"> <?rev put tDefinition ?> </p>
</div>
</body>


but what would be "neat" easier and clearer would be (this is a fantasy 
chunk.. but gives you the idea...)


<?rev
if len(tDefinition) > 350 then ?>

# then use this plain html

div style=\"margin: 15px;padding:2px 15px 2px 15px;\">
img src="/resources/lexicon/images/backgrounds/EyeGlass.jpg" 
style="float:left; margin-right:12px;" />

<?rev
else
?>

# use this plain html instead

<div style="margin: 15px;background-color: #FFFFFF;padding:2px 15px 2px 
15px; opacity: 0.90">

<?rev
end if
?>

<h1 style="text-shadow: +10% +10% 10% rgb(153,153,153);"><?rev put tWord 
?>:</h1>
<p style:"font-size: 115%;"> <?rev put tDefinition ?> </p>
</div>

i.e. goal: based on conditionals, case statement etc. swap out entire 
chunks of html without having to build those strings in the code itself, 
but rather "talk" to the page as in: "Use this next section of html" or 
"skip this next section of html"

Any ideas?  Note: I do not know a single drop of javascript,

Sivakatirswami






More information about the use-livecode mailing list