EJS will meet my needs [which presently are far from the complexity of
the NBA example].
I have 2 questions.
(1) I have a JSON txt file containing product data in the same folder
as my html product pages. There are 400 items with about 24
attributes, but consider the mock "products.json" file below.
--------------------------------------------------------
[{
"scode":"10001_102",
"name":"U of M Sun Glasses",
"price":"9.95",
"keywords":"U of M, Tigers, College Gifts, Sun Glasses",
"cond1":"Gift Item",
"desc1":"Safety Glasses",
"cond2":"School",
"desc2":"U of M",
},
{
"scode":"10001_106",
"name":"Penn State Umbrella",
"price":"9.95",
"keywords":"Penn State, Umbrella, College Gifts, Sun Glasses",
"cond1":"Gift Item",
"desc1":"Safety Glasses",
"cond2":"School",
"desc2":"U of M",
},
]
---------------------------------------------------
I want to do a simple template that accesses the data from
"products.json".
I'm really not processing the data, other than selecting specific
array items. However, I'm not certain how to reference the JSON
file.
If my template looked something like the following, what would I need
to add to reference specific individual elements/attributes of
specific array items?
[I will need to reference elements, like "scode" several times for
each.]
-------------------------------------------------
<h2><%= name[i] %></h2>
<p>
<a href="
http://mydomain.com/images/<%= scode[i] %>/lg1.jpg"
rel="thumbnail" title="<%= name[i] %>">
<img src="
http://mydomain.com/images/<%= scode[i] %>/lg1.jpg"
alt="thumb" /></a>
</p>
<h3><%= price[i] %></h3>
<div>
<%= cond1[i] %>: <%= desc1[i] %><br/>%>
<%= cond2[i] %>: <%= desc2[i] %><br/>%>
</div>
-----------------------------------------------------
And (2), is there a way, using only a combination of javascript, json,
or XML to dynamically create meta tags like keywords and the page
title tag? I'm reading a book on jquery, but initial searches seem to
indicate "No".
-----------------------------------------------------
Many Thanks for your help.
MavisB