Skip to content

Instantly share code, notes, and snippets.

@herberthobregon
Last active October 28, 2020 13:17
Show Gist options
  • Save herberthobregon/f86697482bc30c9f898b182bfd15fd4e to your computer and use it in GitHub Desktop.
Save herberthobregon/f86697482bc30c9f898b182bfd15fd4e to your computer and use it in GitHub Desktop.
Polymer 3 Code Template for WebStom, PhpStorm, All JetBrains IDE
#set($CLASS_NAME = "")
#set($part = "")
#if($NAME.endsWith(".js"))
#set($end = $NAME.length() - 3)
#set($NAME = "$NAME.substring(0,$end)")
#end
#foreach($part in $NAME.split("-"))
#set($CLASS_NAME = "${CLASS_NAME}$part.substring(0,1).toUpperCase()$part.substring(1).toLowerCase()")
#end
import { LitElement, html } from 'lit-element/lit-element.js';
class ${CLASS_NAME} extends LitElement {
constructor() {
super();
// Default properties can be set from the element's constructor
this.mood = "Hello ${NAME}"
}
static get properties() {
return {
mood: String
};
}
render() {
return html`
<style>
:host {
display: block;
}
</style>
<div>Lit-element! ${this.mood}!</div>
`;
}
}
window.customElements.define('${NAME}', ${CLASS_NAME});
#set($CLASS_NAME = "")
#set($part = "")
#if($NAME.endsWith(".js"))
#set($end = $NAME.length() - 3)
#set($NAME = "$NAME.substring(0,$end)")
#end
#foreach($part in $NAME.split("-"))
#set($CLASS_NAME = "${CLASS_NAME}$part.substring(0,1).toUpperCase()$part.substring(1).toLowerCase()")
#end
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
class ${CLASS_NAME} extends PolymerElement {
static get properties() {
return {};
}
static get template() {
return html`
<style>
:host {
display: block;
}
</style>
<div>Hola mundo! Polymer 3</div>
`;
}
}
window.customElements.define('${NAME}', ${CLASS_NAME});
@herberthobregon
Copy link
Author

herberthobregon commented May 17, 2018

Add in
Settings > Editor > File and code Templates

now simply
right click in folder > new > [Name of your template]

Name: "my-element"

@herberthobregon
Copy link
Author

Edited

Change _render to render

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