Skip to content

Commit

Permalink
feat(syntax) mandatory <script> tag for JS content
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-g committed Sep 26, 2014
1 parent 0399c85 commit db7227e
Show file tree
Hide file tree
Showing 87 changed files with 428 additions and 80 deletions.
2 changes: 1 addition & 1 deletion build/grunt/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ module.exports = function(grunt) {
process: function(content) {
var compiled = renderer.renderString(content, "inline.js");
if (compiled.serverErrors && compiled.serverErrors.length) {
grunt.fail.fatal("Hashspace compilation " + compiled.serverErrors[0].description);
grunt.fail.fatal("\r\nHashspace compilation of " + file + "\r\n" + compiled.serverErrors[0].description);
return false;
}
return compiled.code;
Expand Down
4 changes: 4 additions & 0 deletions docs/playground/layout.hsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<script>
var splitter = require("./splitter.hsp.js");
var plunkerExport = require("./plunker.js");

Expand Down Expand Up @@ -28,6 +29,7 @@ var DescriptionCtrl = Class({
this.after = parts[1];
}
});
</script>

<template desc using ctrl:DescriptionCtrl>
<div id="description">
Expand Down Expand Up @@ -69,6 +71,7 @@ var DescriptionCtrl = Class({
</div>
</template>

<script>
function splitterReleased(position, data, playground) {
data.splitterPos = position + "px";
editorResize(playground);
Expand Down Expand Up @@ -100,6 +103,7 @@ function hideNavHover(event, data) {
data.navHover = false;
}
}
</script>

<template sampleList(data, playground)>
<div class="samples-list {{'samples-list-collapsed': data.navCollapsed}}"
Expand Down
5 changes: 4 additions & 1 deletion docs/playground/splitter.hsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<script>
var Class = require("hsp/klass");

var SplitterCtrl = Class({
Expand Down Expand Up @@ -71,11 +72,13 @@ var SplitterCtrl = Class({
element.style[this.type === "vertical" ? "top" : "left"] = position + "px";
}
});

</script>

<template splitter using controller:SplitterCtrl>
<div class="splitter" onmousedown="{controller.onMouseDown(event)}"></div>
<div class="splitter-proxy {{'splitter-proxy-hidden': !controller.active}}"></div>
</template>

<script>
module.exports = splitter;
</script>
4 changes: 4 additions & 0 deletions docs/samples/clickhandler/clickhandler.hsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>
var msg={text:""}, count=-1;
</script>

<template message(msg)>
<div title="click me!" onclick="{changeMessage()}" onselectstart="return false">
Expand All @@ -7,6 +9,7 @@ var msg={text:""}, count=-1;
</div>
</template>

<script>
function changeMessage() {
count++;
switch(count%3) {
Expand Down Expand Up @@ -36,3 +39,4 @@ module.exports = {
template: message,
data: [msg]
};
</script>
4 changes: 4 additions & 0 deletions docs/samples/clock/clock.hsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<script>
var klass=require("hsp/klass");

var CITIES={
Expand Down Expand Up @@ -41,6 +42,7 @@ var ClockController=klass({
this.cityName = CITIES[this.city].city;
}
});
</script>

<template clock using c:ClockController>
// example from http://www.ractivejs.org/examples/clock/
Expand Down Expand Up @@ -75,8 +77,10 @@ var ClockController=klass({
<#clock city="TYO"/>
</template>

<script>
// Needed by the playground application.
// Update it, but do not remove it!
module.exports = {
template: demo
};
</script>
5 changes: 4 additions & 1 deletion docs/samples/component1/timer.hsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<script>
var klass=require("hsp/klass");

// klass is a utility to create JS objects with constructors & prototypes
Expand All @@ -16,6 +17,7 @@ var Timer=klass({
this.secondsElapsed++;
}
});
</script>

<template timer using t:Timer>
Elapsed time: {t.secondsElapsed}s
Expand All @@ -27,9 +29,10 @@ var Timer=klass({
<#timer initvalue="10"/>
</template>


<script>
// Needed by the playground application.
// Update it, but do not remove it!
module.exports = {
template: test
};
</script>
11 changes: 10 additions & 1 deletion docs/samples/component2/nbrfield.hsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<script>
var klass=require("hsp/klass");

// Component controller
Expand Down Expand Up @@ -68,8 +69,12 @@ function getNumber(s) {
if (!NBR_DIGITS.test(s)) return null;
return Number(s);
}
</script>

<script>
// component template associated with the NbrField controller
</script>

<export template nbrfield using c:NbrField>
<span class="nbrfield">
<input type="text" model="{c.internalValue}"
Expand All @@ -78,7 +83,10 @@ function getNumber(s) {
</span>
</template>

<script>
// component usage
</script>

<template test(d)>
Component #1: <#nbrfield value="{d.value1}" min="-10" max="1000"/><br/>
Value in the data model: <span class="textValue">{d.value1}</span>
Expand All @@ -88,10 +96,11 @@ function getNumber(s) {
Value in the data model: <span class="textValue">{d.value2}</span>
</template>


<script>
// Needed by the playground application.
// Update it, but do not remove it!
module.exports = {
template: test,
data: [{ value1 : 123 }]
};
</script>
4 changes: 4 additions & 0 deletions docs/samples/component3/pagination.hsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<script>
var klass=require("hsp/klass");

function calculateNoOfPages(collectionSize, pageSize) {
Expand Down Expand Up @@ -42,6 +43,7 @@ var Pagination=klass({
rebuildInternalModel(this);
}
});
</script>

<template pagination using p:Pagination>
<ul class="pagination">
Expand Down Expand Up @@ -71,6 +73,7 @@ var Pagination=klass({

</template>

<script>
var model = {
active: 4,
collectionSize: 99,
Expand All @@ -88,3 +91,4 @@ module.exports = {
template: paginationTest,
data: [model]
};
</script>
6 changes: 6 additions & 0 deletions docs/samples/conditions/conditions.hsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<script>
var klass=require("hsp/klass");
</script>

<script>
// nt is an instance of NumberTester
</script>
<template test(nt)>
<div>
Number: <span class="textvalue">{nt.number}</span>
Expand All @@ -23,6 +27,7 @@ var klass=require("hsp/klass");
</div>
</template>

<script>
// klass is a little utility to create a JS object constructor
// from a simple JSON structure - main goals are to
// to simplify prototypal inheritance and ease code reading
Expand All @@ -44,3 +49,4 @@ module.exports = {
return [new NumberTester()];
}
};
</script>
2 changes: 2 additions & 0 deletions docs/samples/cssclass/cssclass.hsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</div>
</template>

<script>
var msg={
text:"Hello World",
urgency:false
Expand All @@ -32,3 +33,4 @@ module.exports = {
template: message,
data: [msg]
};
</script>
2 changes: 2 additions & 0 deletions docs/samples/dynpath/dynpath.hsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<a href="javascript:void(0)" onclick="{swapC()}">Show/Hide columns C</a>
</template>

<script>
// create dummy data
var list=[], count=5;
for (var i=0;count>i;i++) {
Expand Down Expand Up @@ -57,3 +58,4 @@ module.exports = {
template: grid,
data: [model]
};
</script>
2 changes: 2 additions & 0 deletions docs/samples/dyntemplates/dyntemplates.hsp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</div>
</template>

<script>
var model={
view: tplA,
msg: "Hello World",
Expand All @@ -33,3 +34,4 @@ module.exports = {
template: test,
data: [model]
};
</script>
4 changes: 4 additions & 0 deletions docs/samples/gestures/gestures.hsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>
require('hsp/gestures/index').register();
</script>

<template gestures(msgList)>
<div class="touchboard" style="height:200px; background: #27AAFC;text-align:center;"
Expand All @@ -19,6 +21,7 @@ require('hsp/gestures/index').register();
</div>
</template>

<script>
var eventLog = [];

function addMsg(evt) {
Expand All @@ -36,3 +39,4 @@ module.exports = {
template: gestures,
data: [eventLog]
};
</script>
6 changes: 6 additions & 0 deletions docs/samples/global/global.hsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>
var hsp=require("hsp/rt");
</script>

<template item(text,value)>
{if value}
Expand All @@ -9,8 +11,10 @@ var hsp=require("hsp/rt");
{/if}
</template>

<script>
hsp.global.label=item;
hsp.global.ln={personDetails:"Person details"};
</script>

<template test(person)>
<div class="global" title="{ln.personDetails}">
Expand All @@ -19,6 +23,7 @@ hsp.global.ln={personDetails:"Person details"};
</div>
</template>

<script>
// Needed by the playground application.
// Update it, but do not remove it!
module.exports = {
Expand All @@ -28,3 +33,4 @@ module.exports = {
lastName:"Simpson"
}]
};
</script>
5 changes: 5 additions & 0 deletions docs/samples/helloworld/hello.hsp
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<script>
// edit me!
</script>

<template hello(name)>
<div class="msg">
Hello {name}!
</div>
</template>

<script>
// Needed by the playground application.
// Update it, but do not remove it!
module.exports = {
template: hello,
data: ["World"]
};
</script>
2 changes: 2 additions & 0 deletions docs/samples/inputsample/inputsample.hsp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
</div>
</template>

<script>
var d={comment:"edit me!", isChecked:false, selection:"B", dtype:"text"}

// Needed by the playground application.
Expand All @@ -39,3 +40,4 @@ module.exports = {
template: inputSample,
data: [d]
};
</script>
2 changes: 2 additions & 0 deletions docs/samples/let/let.hsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<a href="javascript:void(0)" onclick="{updateModel()}">Change Model</a>
</template>

<script>
var model={
part1:{
part11: {msg: "Message 1.1"}
Expand All @@ -35,3 +36,4 @@ module.exports = {
template: test,
data: [model]
};
</script>
9 changes: 9 additions & 0 deletions docs/samples/list1/list.hsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<script>
var klass=require("hsp/klass");

// simple list controller
Expand All @@ -12,8 +13,12 @@ var ListController = klass({
"separator": {type:"template"}
}
});
</script>

<script>
// simple list template
</script>

<template list using lc:ListController>
// content is the list of attribute sub-elements
<div class="list {lc.class}">
Expand All @@ -36,7 +41,9 @@ var ListController = klass({
</div>
</template>

<script>
// test template
</script>
<template test(d)>
<#list head="Static list" class="listcpt">
<@option>First {d.itemName}</@option>
Expand All @@ -60,6 +67,7 @@ var ListController = klass({
</#list>
</template>

<script>
var count=0, model={
itemName: "item",
preferredOption:"My favourite things",
Expand Down Expand Up @@ -87,3 +95,4 @@ module.exports = {
template: test,
data: [model]
};
</script>
Loading

1 comment on commit db7227e

@jakub-g
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PR #308

Please sign in to comment.