Wondering what’s next for npm?Check out our public roadmap! »

wcs-microdata

0.4.1 • Public • Published

wcs-microdata Build Status

Web components mixin to support microdata properties.

To install wcs-microdata run the following:

> npm install wcs-microdata --save

You can then decorate your custom elements as follows:

import { MicrodataMixin } from '../wcs-microdata.js'
import { LitElement, html } from 'lit-element'
 
class MyMicrodataElement extends MicrodataMixin(LitElement) {
 
  static get is() { return 'my-microdata-element' }
 
  static get properties() {
    return {
      name: {
        type: String
      }
    }
  }
 
  render() {
    return html`<span id="name">${this.name}</span>`
  }
}
 
customElements.define(MyMicrodataElement.is, MyMicrodataElement)
 

You can then populate your element properties using microdata syntax as follows:

<my-microdata-element itemscope>
  <span itemprop="name">my-name</span>
</my-microdata-element>

This should render as:

<p>my-name</p>

Hacking

To modify polymer-microdata you need the following installed:

Once you've cloned the repo run the following shell commands:

> npm install

You can run the tests as follows:

> npm test

Or you can run the test suite in your browser by running polymer serve --open and copy-and-pasting http://127.0.0.1:8081/components/polymer-microdata/test/ into your address bar.

Install

npm i wcs-microdata

DownloadsWeekly Downloads

1

Version

0.4.1

License

MIT

Unpacked Size

10.5 kB

Total Files

12

Last publish

Collaborators

  • avatar