Skip to content

Instantly share code, notes, and snippets.

@shabith
Last active August 29, 2015 14:08
Show Gist options
  • Save shabith/41162dd312b02a3a4f74 to your computer and use it in GitHub Desktop.
Save shabith/41162dd312b02a3a4f74 to your computer and use it in GitHub Desktop.
Javascript Scaffold Template

#Javascript Scaffold Template

##Instructions

Replace PN with Project Name Abbrivation. Make it Simple and CAP, and make sure it doesn't be longer than 3 Characters.

Replace page-name with Page Name (Obviously!). Make it simple and understandable.

##PhpStrom/WebStrom Template

###How to Install

Windows

Go to C:\Users\USERNAME\.WebIde70\config\templates' and place *js-template.xml* Replace**USERNAME** with your username and **.WebIde70** with your PhpStrom/WebStrom version Restart PhpStrom/WebStrom and type tmpl` press TAB

<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="user">
<template name="tmpl" value="/*global $proj$, NS */&#10;&#10;&quot;use strict&quot;;&#10;&#10;var $proj$ = (typeof $proj$==='object') ? $proj$ : {};&#10;&#10;$proj$.$page$ = {&#10; VAR: {&#10; //variables&#10; },&#10;&#10;&#10; init: function(){&#10; //initialization&#10; $END$&#10; }&#10;&#10;};&#10;&#10;jQuery(function(){&#10; $proj$.$page$.init();&#10;});" description="Javascript File Template for Magento" toReformat="false" toShortenFQNames="true">
<variable name="proj" expression="" defaultValue="PROJECT_NAME" alwaysStopAt="true" />
<variable name="page" expression="" defaultValue="page_type" alwaysStopAt="true" />
<context>
<option name="HTML_TEXT" value="false" />
<option name="HTML" value="false" />
<option name="XSL_TEXT" value="false" />
<option name="XML" value="false" />
<option name="JSP" value="false" />
<option name="CSS_PROPERTY_VALUE" value="false" />
<option name="CSS_DECLARATION_BLOCK" value="false" />
<option name="CSS_RULESET_LIST" value="false" />
<option name="CSS" value="false" />
<option name="JAVA_SCRIPT" value="true" />
<option name="TypeScript" value="false" />
<option name="SQL" value="false" />
<option name="CUCUMBER_FEATURE_FILE" value="false" />
<option name="CoffeeScript" value="false" />
<option name="HAML" value="false" />
<option name="PHP" value="false" />
<option name="OTHER" value="false" />
</context>
</template>
<template name="log" value="console.log($END$);" description="Console Log" toReformat="false" toShortenFQNames="true">
<context>
<option name="HTML_TEXT" value="false" />
<option name="HTML" value="false" />
<option name="XSL_TEXT" value="false" />
<option name="XML" value="false" />
<option name="JSP" value="false" />
<option name="CSS_PROPERTY_VALUE" value="false" />
<option name="CSS_DECLARATION_BLOCK" value="false" />
<option name="CSS_RULESET_LIST" value="false" />
<option name="CSS" value="false" />
<option name="JAVA_SCRIPT" value="true" />
<option name="TypeScript" value="false" />
<option name="SQL" value="false" />
<option name="CUCUMBER_FEATURE_FILE" value="false" />
<option name="CoffeeScript" value="false" />
<option name="HAML" value="false" />
<option name="PHP" value="false" />
<option name="OTHER" value="false" />
</context>
</template>
</templateSet>
/**
* Javascript Scaffold Template
*
* Instructions
* ============
*
* Replace 'PN' with Project Name Abbrivation.
* Make it Simple and CAP, and make sure it doesn't be longer than 3 Characters.
*
* Replace 'page-name' with Page Name (Obviously!). Make it simple and understandable.
/*global PN, NS */
"use strict";
var PN = (typeof PN==='object') ? PN : {};
PN.page-name = {
VAR: {
//variables
},
init: function(){
//initialization
}
};
jQuery(function(){
//on page load call initialization method
PN.page-name.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment