Skip to content

Polymer 2.0 elements#52

Open
nkrim wants to merge 4 commits intorobdodson:masterfrom
nkrim:polymer-2-elements
Open

Polymer 2.0 elements#52
nkrim wants to merge 4 commits intorobdodson:masterfrom
nkrim:polymer-2-elements

Conversation

@nkrim
Copy link

@nkrim nkrim commented Mar 15, 2017

Snippets that are relatively synonymous with the pe and pes snippets, but with the new ES6 spec used with polymer 2.0.

The pe2 and pes2 shortcuts are used to generate the boilerplate element code, the latter being near-identical but with an external stylesheet reference instead. Could also be logically changed to p2e, or replace pe and have the original polymer element snippet have a different shortcut, such as pel (for legacy).

For both, the tab fields follow similarly to their legacy counterparts, with $1 at the start polymer import path, $2 filling in the name of the element in all relevant fields, and, for the external stylesheet snippet, $3 is used to fill the name of the stylesheet to use.

There is also a regex substitution in 3 places that turns the $2 field from its expected slug-case to camelCase for use as the class name at declaration, and in the two arguments of the final window.customElements.define() call for the element.

Other than the regex-replacement, the only other relative difference from the original polymer element snippets are a default properties definition, with one property named prop1 that has a string value set by field $2 and a <h2>Hello [[prop1]]</h2> in the template (similar to the polymer-cli element boilerplate).

@nkrim nkrim mentioned this pull request Mar 15, 2017
@nkrim
Copy link
Author

nkrim commented Mar 16, 2017

Made some fixes, can close and make a new pull request if desired:

  • $1 path placeholder as ../../bower_components
  • spaces converted to tabs

@@ -0,0 +1,49 @@
<snippet>
<content><![CDATA[
<link rel="import" href="${1:../../bower_components}/polymer/polymer.html">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be polymer/polymer-element.html now?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants