You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-42Lines changed: 35 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
-
#### This is pre-release software. Use at your own risk.
2
-
# microdata-template
1
+
######This is released software. Please **[log issues](https://github.com/ptrdo/microdata-template/issues)** found.
2
+
# microdata-template`v2.0.0`
3
3
An implementation of HTML template by way of the microdata mechanism.
4
4
### The Gist
5
5
This JavaScript module should simplify adding dynamic content to HTML documents while staying true to the recommendations of web standards. There are no dependencies here except the JavaScript [ECMA5 standard](http://www.ecma-international.org/ecma-262/5.1/) which enjoys [nearly universal support](http://kangax.github.io/compat-table/es5/) in modern browsers. Also, since the HTML recommendations for integral technologies such as [template](https://www.w3.org/TR/html52/semantics-scripting.html#the-template-element) and [microdata](https://www.w3.org/TR/microdata/) are variably implemented by modern browsers, this module serves as a [polyfill](https://en.wikipedia.org/wiki/Polyfill) to assure reliable results. Best of all, this methodology encourages the writing of low-dependency JavaScript and perfectly valid HTML — even within fully-functional templated markup.
@@ -11,7 +11,8 @@ This JavaScript module should simplify adding dynamic content to HTML documents
var templater =newPTRDO.utils.MicrodataTemplate();
90
-
});
91
-
</script>
92
-
```
93
-
This module is organized to be attached to an HTML document as a simple external script, but also in a project governed by [Asynchronous Module Definition](https://en.wikipedia.org/wiki/Asynchronous_module_definition) (AMD) with a library such as [RequireJS](https://github.com/requirejs/requirejs), or a [CommonJS](https://en.wikipedia.org/wiki/CommonJS) project governed by a framework such as [NodeJS](https://en.wikipedia.org/wiki/Node.js). The expectations are the same, but the syntax used to load, instantiate, and then address the module will be as a local reference rather than a window namespace.
81
+
This module is organized to be attached to an HTML document as a simple external script (see: [Simple Usage](https://github.com/ptrdo/microdata-template#simple-usage)), but also in a project governed by [Asynchronous Module Definition](https://en.wikipedia.org/wiki/Asynchronous_module_definition) (AMD) with a library such as [RequireJS](https://github.com/requirejs/requirejs), or an [ES6-compliant](http://es6-features.org/) project bundled by a library such as [Webpack](https://webpack.js.org/). The expectations are the same, but the syntax used to load, instantiate, and then address the module may be slightly different depending on circumstance.
94
82
95
-
**AMD (RequireJS) Implementation:**
83
+
**Old-fashioned AMD (RequireJS) Implementation:**
96
84
```javascript
97
85
require.config({
98
-
paths: { auth:"/path/to/idmorg-auth"},
99
-
shim: { auth: { exports:"auth" }}
86
+
paths: {
87
+
text:"./node_modules/requirejs-text/text",
88
+
json:"./node_modules/requirejs-json/json",
89
+
}
100
90
});
101
-
102
-
define(["auth"], function(Auth) {
103
-
Auth.init({
104
-
applicationName:"SomeAppName",
105
-
endpoint:"https://comps-dev.idmod.org/api/",
106
-
parentElement: someDOMElement
107
-
});
108
-
109
-
Auth.signout();
91
+
define(
92
+
[
93
+
"./path/to/microdata-template.js",
94
+
"json!./path/to/collection.json"
95
+
],
96
+
function(templater, collection) {
97
+
98
+
varrender=function(rootElement) {
99
+
var templateElement =rootElement.querySelector("TR[itemscope]");
###### This is released software. Please **[log issues](https://github.com/ptrdo/microdata-template/issues)** found.
2
+
# Examples of microdata-template
3
+
These samples demonstrate implementations of the microdata-template utility for rendering a variety of data to an HTML page. Clone this project and then follow the instructions (below) which are most-appropriate for application.
4
+
5
+
***
6
+
### simple-javascript
7
+
This example includes HTML documents which can be run directly in a web browser. A web server (or localhost) is recommended for demonstrating complete functionality in real-world circumstance, but is not required. All links are relative, including to the data sources and the microdata-template library.
8
+
9
+
***
10
+
### minimal-requirejs
11
+
This example demonstrates integration into a minimal [Asynchronous Module Definition](https://en.wikipedia.org/wiki/Asynchronous_module_definition) (AMD) project governed by the [RequireJS](https://github.com/requirejs/requirejs) library. An enclosed `package.json` designates all dependencies required for running the demonstration.
12
+
13
+
[Yarn](https://yarnpkg.com/) is an excellent choice for managing packages for web clients and can be [installed a variety of ways](https://yarnpkg.com/en/docs/install). Alternatively, the Node Package Manager ([NPM](https://www.npmjs.com/get-npm)) can also be used.
14
+
15
+
**1:** From a command prompt, navigate to the project path where the clone of this repository is installed, and then the path where the relevant `package.json` file exists.
**2:** From a command prompt, run the Yarn `install` command to get the dependencies as prescribed in the `package.json` file. This will create a path local to this example `\node_modules` for deposit of the downloaded code.
20
+
```sh
21
+
> yarn install
22
+
```
23
+
**3:** The file to run is `\minimal-requirejs\www\index.html`. A `localhost` or other webserver will be required for the page to import all runtime components and then render without error. One convenient means is use an Integrated Development Environment (IDE) such as JetBrain's [WebStorm](https://www.jetbrains.com/webstorm/) or [IntelliJ](https://www.jetbrains.com/idea/) which can open these files for review and edit and then run them in its internal webserver.
24
+
25
+
***
26
+
### minimal-webpack
27
+
This example demonstrates integration into a minimal [ES6-compliant](http://es6-features.org/) project bundled by the [Webpack](https://webpack.js.org/) library. An enclosed `package.json` designates all dependencies required for running the demonstration.
28
+
29
+
[NodeJS](https://nodejs.org/en/download/) is a technology which can execute scripts on a computer. In this application, NodeJS fasciliates the Webpack framework in assembling the various ingredients of the Client code, preparing them for deployment to a browser. It will be necessary to install NodeJS to run these examples.
30
+
31
+
The Node Package Manager ([NPM](https://www.npmjs.com/get-npm)) is installed as a component of NodeJS and is a popular means for executing the `package.json` of a project.
32
+
33
+
**1:** From a command prompt, navigate to the project path where the clone of this repository is installed, and then the path where the relevant `package.json` file exists.
**2:** From a command prompt, run the NPM `install` command to get the dependencies as prescribed in the `package.json` file. This will create a path local to this example `\node_modules` for deposit of the downloaded code.
38
+
```sh
39
+
> npm install
40
+
```
41
+
**3:** From a command prompt, run the NPM `start` command which has been configured in the `webpack.config.js` to instruct Webpack to survey the dependencies prescribed in the project code and then compile the bundled JavaScript.
42
+
```sh
43
+
> npm start
44
+
```
45
+
**4:** Open a browser and navigate to `http://localhost:8080` to view the deployed code. Note: If this does not work, there may be a conflict with other processes, so th `8080` port can be changed by [configuring the devServer](https://webpack.js.org/configuration/dev-server/).
0 commit comments