couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hank Knight <hknight...@gmail.com>
Subject CouchDB: Parsing Template Attachements (Feature Request)
Date Sun, 12 Jan 2014 21:04:39 GMT
I would like a new feature to be added to CouchDB that would
attachments added to design documents to be parsed to support
JavaScript.

When adding an attachment to a design document, if the value of
"template" is set to true then code between <% and %> should be
processed with JavaScript.

Would anybody else like this feature?

Are there reasons why this would be a good or bad idea?

How much time would it take to develop this?

An example is below.

---------------------------------
<html>
<body>

<h1>
Current Timestamp:
<%
return Math.round(new Date().getTime()/1000);
%>
</h1>

<h1>
Your IP Address:
<%
return req.peer;
%>
</h1>

<h1>
Document Revision Number:
<%
return doc._rev;
%>
</h1>

<h1>
Document Revision Number of docid:
<%

var myDoc = getDoc('db/docid');
return myDoc._rev;

%>
</h1>

<h1>
Content from show function:
<%

var myShow = getShow('db/_design/showxe/_show/xyz');
return myShow;

%>
</h1>

<h1>
Content from list function:
<%

var myList = getShow('db/_design/listx/_list/abc/xyz?limit=3');
return myShow;

%>
</h1>

</body>
</html>

-------------------------------------
That should return something like this:
-------------------------------------

<html>
<body>

<h1>
Current Timestamp: 1389542068
</h1>

<h1>
Your IP Address: 22.33.44.55
</h1>

<h1>
Document Revision Number: 2-dc390c2c2f5cb5b2a4431a49a8fc60a3
</h1>

<h1>
Document Revision Number of docid: 1-ac390c2a1f5cb5b2a1431a49a2fc31a2
</h1>

<h1>
Content from show function: Hello World
</h1>

<h1>
Content from list function: 1 2 3 4 5
</h1>

</body>
</html>

Mime
View raw message