New Operation: Meta #198

Closed
neocotic opened this Issue May 17, 2013 · 2 comments

Comments

Projects
None yet
1 participant
@neocotic
Member

neocotic commented May 17, 2013

User Yuriy Zubarev has suggested that HTML meta tag information is accessible in templates. This is a great idea and I hope to include it in the next release.

The string that is passed into the new meta operation will be used to get the value of the content attribute for the element with a matching name or http-equiv attribute, since it should have exactly one of them according to the w3c HTML5 documentation (ignoring the charset attribute - the characterSet standard variable deals with that). The argument will not be case sensitive.

Example

HTML:

<meta name="description" content="The homepage for the Template browser extension">
<meta http-equiv="Refresh" content="5; url=http://template-extension.org">

Template:

{#meta}description{/meta}
{#meta}refresh{/meta}

Output:

The homepage for the Template browser extension
5; url=http://template-extension.org

Brain dump

Since this operation will need to interact with the DOM it probably makes sense for content.coffee to return a key/value map (all keys in lower case) for all applicable meta tags and to then add the meta operation function to the data object which will still be in scope to access the map.

Also, since it's interacting with the content script, this operation will not run on protected pages.

@ghost ghost assigned neocotic May 17, 2013

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 19, 2013

Member

I've decided that I'm also going to support the unofficial 'property' attribute for the meta element. This is in no way supported by W3C as far as I know, but a lot of libraries/frameworks use this so I thought I'd at least support it as the final fallback. It will be ignored if either a name or http-equiv attribute exists.

Member

neocotic commented May 19, 2013

I've decided that I'm also going to support the unofficial 'property' attribute for the meta element. This is in no way supported by W3C as far as I know, but a lot of libraries/frameworks use this so I thought I'd at least support it as the final fallback. It will be ignored if either a name or http-equiv attribute exists.

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 19, 2013

Member

The new meta operation has been implemented by neocotic/template-chrome#3.

Member

neocotic commented May 19, 2013

The new meta operation has been implemented by neocotic/template-chrome#3.

@neocotic neocotic closed this May 19, 2013

@neocotic neocotic added the accepted label Nov 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment