You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by David Goodenough <da...@linkchoose.co.uk> on 2010/08/11 11:21:44 UTC

Template file names

I want to be able to develop CouchDB apps using the Eclipse plugin and
I want to use templates.  

Templates have <%...%> tags in them, and the Helios (Eclipse 3.6) HTML
validator objects, saying this is not valid HTML (which is true).  However if
I called these file .jsp rather than .html it would be legal.  

So my question is whether the template system cares about file extensions
and whether this has any effect on things like content types?

David

Re: Template file names

Posted by J Chris Anderson <jc...@apache.org>.
On Aug 12, 2010, at 11:00 AM, David Goodenough wrote:

> On Thursday 12 August 2010, J Chris Anderson wrote:
>> On Aug 12, 2010, at 5:27 AM, David Goodenough wrote:
>>> My question was not so much about which template system to use
>>> as about whether the template system had any sensitivity to the
>>> file extension of the template files, in particular does it set the
>>> content-type from the extension.
>> 
>> No, the templates are stored as part of the JSON document bodies, so 
> there
>> is no content type. The `couchapp` script removes extensions when 
> pushing.
>> There are other design document management tools which do not 
> remove
>> extensions. It's really up to you. I've chosen to remove extensions
>> because it makes it easier to address templates etc in JavaScript.
> So when the file is served what header Content-Type is set?
> 

The file, when embedded in the JSON document, is served as JSON. See, for instance:

http://jchris.couchone.com/proto/_design/proto

(It's a giant JSON blob with some templates embedded in it)

Of course, binary attachments are served with the content type they are PUT with, eg, see:

http://jchris.couchone.com/toast/_design/toast/images/icon.png

Chris


> David
>> 
>> Chris
>> 
>>> David
>>> 
>>> On Wednesday 11 August 2010, Chris Anderson wrote:
>>>> CouchDB doesn't care which template system you use. There are 
> lots of
>>> 
>>> them
>>> 
>>>> implemented in JavaScript. You might also look at Mustache.js.
>>>> 
>>>> For the one you have now .erb might provide good highlighting too.
>>>> 
>>>> Typed on glass.
>>>> 
>>>> On Aug 11, 2010, at 2:21 AM, David Goodenough
>>> 
>>> <da...@linkchoose.co.uk> wrote:
>>>>> I want to be able to develop CouchDB apps using the Eclipse plugin
>>> 
>>> and
>>> 
>>>>> I want to use templates.
>>>>> 
>>>>> Templates have <%...%> tags in them, and the Helios (Eclipse 
> 3.6)
>>> 
>>> HTML
>>> 
>>>>> validator objects, saying this is not valid HTML (which is true).
>>>>> However if I called these file .jsp rather than .html it would be
>>>>> legal.
>>>>> 
>>>>> So my question is whether the template system cares about file
>>> 
>>> extensions
>>> 
>>>>> and whether this has any effect on things like content types?
>>>>> 
>>>>> David
> 


Re: Template file names

Posted by David Goodenough <da...@linkchoose.co.uk>.
On Thursday 12 August 2010, J Chris Anderson wrote:
> On Aug 12, 2010, at 5:27 AM, David Goodenough wrote:
> > My question was not so much about which template system to use
> > as about whether the template system had any sensitivity to the
> > file extension of the template files, in particular does it set the
> > content-type from the extension.
> 
> No, the templates are stored as part of the JSON document bodies, so 
there
> is no content type. The `couchapp` script removes extensions when 
pushing.
> There are other design document management tools which do not 
remove
> extensions. It's really up to you. I've chosen to remove extensions
> because it makes it easier to address templates etc in JavaScript.
So when the file is served what header Content-Type is set?

David
> 
> Chris
> 
> > David
> > 
> > On Wednesday 11 August 2010, Chris Anderson wrote:
> >> CouchDB doesn't care which template system you use. There are 
lots of
> > 
> > them
> > 
> >> implemented in JavaScript. You might also look at Mustache.js.
> >> 
> >> For the one you have now .erb might provide good highlighting too.
> >> 
> >> Typed on glass.
> >> 
> >> On Aug 11, 2010, at 2:21 AM, David Goodenough
> > 
> > <da...@linkchoose.co.uk> wrote:
> >>> I want to be able to develop CouchDB apps using the Eclipse plugin
> > 
> > and
> > 
> >>> I want to use templates.
> >>> 
> >>> Templates have <%...%> tags in them, and the Helios (Eclipse 
3.6)
> > 
> > HTML
> > 
> >>> validator objects, saying this is not valid HTML (which is true).
> >>> However if I called these file .jsp rather than .html it would be
> >>> legal.
> >>> 
> >>> So my question is whether the template system cares about file
> > 
> > extensions
> > 
> >>> and whether this has any effect on things like content types?
> >>> 
> >>> David


Re: Template file names

Posted by J Chris Anderson <jc...@apache.org>.
On Aug 12, 2010, at 5:27 AM, David Goodenough wrote:

> My question was not so much about which template system to use
> as about whether the template system had any sensitivity to the
> file extension of the template files, in particular does it set the
> content-type from the extension.
> 

No, the templates are stored as part of the JSON document bodies, so there is no content type. The `couchapp` script removes extensions when pushing. There are other design document management tools which do not remove extensions. It's really up to you. I've chosen to remove extensions because it makes it easier to address templates etc in JavaScript.

Chris

> David
> 
> On Wednesday 11 August 2010, Chris Anderson wrote:
>> CouchDB doesn't care which template system you use. There are lots of 
> them
>> implemented in JavaScript. You might also look at Mustache.js.
>> 
>> For the one you have now .erb might provide good highlighting too.
>> 
>> Typed on glass.
>> 
>> On Aug 11, 2010, at 2:21 AM, David Goodenough 
> <da...@linkchoose.co.uk> wrote:
>>> I want to be able to develop CouchDB apps using the Eclipse plugin 
> and
>>> I want to use templates.
>>> 
>>> Templates have <%...%> tags in them, and the Helios (Eclipse 3.6) 
> HTML
>>> validator objects, saying this is not valid HTML (which is true). 
>>> However if I called these file .jsp rather than .html it would be legal.
>>> 
>>> So my question is whether the template system cares about file 
> extensions
>>> and whether this has any effect on things like content types?
>>> 
>>> David
> 


Re: Template file names

Posted by David Goodenough <da...@linkchoose.co.uk>.
My question was not so much about which template system to use
as about whether the template system had any sensitivity to the
file extension of the template files, in particular does it set the
content-type from the extension.

David

On Wednesday 11 August 2010, Chris Anderson wrote:
> CouchDB doesn't care which template system you use. There are lots of 
them
> implemented in JavaScript. You might also look at Mustache.js.
> 
> For the one you have now .erb might provide good highlighting too.
> 
> Typed on glass.
> 
> On Aug 11, 2010, at 2:21 AM, David Goodenough 
<da...@linkchoose.co.uk> wrote:
> > I want to be able to develop CouchDB apps using the Eclipse plugin 
and
> > I want to use templates.
> > 
> > Templates have <%...%> tags in them, and the Helios (Eclipse 3.6) 
HTML
> > validator objects, saying this is not valid HTML (which is true). 
> > However if I called these file .jsp rather than .html it would be legal.
> > 
> > So my question is whether the template system cares about file 
extensions
> > and whether this has any effect on things like content types?
> > 
> > David


Re: Template file names

Posted by Chris Anderson <jc...@gmail.com>.
CouchDB doesn't care which template system you use. There are lots of them implemented in JavaScript. You might also look at Mustache.js. 

For the one you have now .erb might provide good highlighting too.

Typed on glass.

On Aug 11, 2010, at 2:21 AM, David Goodenough <da...@linkchoose.co.uk> wrote:

> I want to be able to develop CouchDB apps using the Eclipse plugin and
> I want to use templates.  
> 
> Templates have <%...%> tags in them, and the Helios (Eclipse 3.6) HTML
> validator objects, saying this is not valid HTML (which is true).  However if
> I called these file .jsp rather than .html it would be legal.  
> 
> So my question is whether the template system cares about file extensions
> and whether this has any effect on things like content types?
> 
> David