Dear David,
Thanks for your time. But I am still facing the problem. Attached
below is the simplified version of the nobelists example which I tried
to get working. What I want to achieve here is:
if (nobelyear > 1975)
print "young scientist"
else
print "old scientist"
But I always get "old scientist" as the output.
Html I used is:
<html>
<head>
<link href="nobelists.js" type="application/json" rel="exhibit/data" />
<script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"
type="text/javascript"></script>
</head>
<body>
<table width="100%">
<tr valign="top">
<td ex:role="viewPanel">
<table ex:role="lens" class="nobelist">
<tr>
<td>
<div>
<span ex:if=".nobelyear > 1975">
<span>young scientist</span>
<span>old scientist</span>
</span>
<span ex:content=".nobelyear"
class="year"></span>
</div>
</td>
</tr>
</table>
</div>
<div ex:role="view" ex:orders=".nobelyear"
ex:possibleOrders=".label">
</div>
</td>
</tr>
</table>
</body>
</html>
And the nobelists.js I used is:
{
"items" : [
{ type : "Nobelist",
label : "George A. Akerlof",
"nobelyear" : 2001,
},
{ type : "Nobelist",
label : "William Shockley",
"nobelyear" : 1956,
}
],
"properties" : {
"nobelyear" : {
"valueType" : "number"
}
}
}
Please let me know where I am going wrong here.
Cheers,
Ashutosh
------------------------------------------------------------------------------------------------------
Ashutosh Chauhan wrote:
> Dear All,
>
> Since, ex:if-exists doesnt satisfy our needs we plunged into sources
> of exhibit and stumbled upon ex:if , which seems to be quite useful.
> However, I couldnt find any examples of it on the wiki and elsewhere.
> I am curious to know if any 'if-else' kind of construct is possible?
>
It's something like this:
<span ex:if=".age < 10">
<span>kid</span>
<span ex:if=".age < 20">
<span>teenager</span>
<span>adult</span>
</span>
</span>
The first inner element is used if the condition is true, otherwise, the
second element is used.
You can also use ex:select
<span ex:select=".doors">
<span ex:case="4">sedan</span>
<span ex:case="2">coup</span>
<span>can't be classified by number of doors</span>
</span>
You can also use "if" inside attributes:
<div ex:background-style-content="if(.sold = 'true', '#eee',
'white')">...</div>
<img ex:src-subcontent="http://foo.com/{{if(.sold = 'true', 'sold',
'for-sale')}}.png" />
David
_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general