-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for liquidjs template library (v9.0.0) (with sync rende…
…ring)
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<html> | ||
<head> | ||
<script src="../../dom-diff.js"></script> | ||
<script src="../../template-library/liquid.min.js"></script> | ||
<script src="../../sahte-react.js"></script> | ||
</head> | ||
<body> | ||
<div id="myview"></div> | ||
<script> | ||
var view = new SahteReact({ | ||
template: | ||
`<div on-click="onClick"> | ||
<span ref="spanEl">{{ text }}</span> | ||
</div>` | ||
, | ||
data: { text: 'Test' }, | ||
target: '#myview', | ||
onClick: function () { | ||
console.log('Clicked!'); | ||
} | ||
}); | ||
view.mount(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<html> | ||
<head> | ||
<script src="../../dom-diff.js"></script> | ||
<script src="../../template-library/liquid.min.js"></script> | ||
<script src="../../sahte-react.js"></script> | ||
</head> | ||
<body> | ||
<div id="myview1"></div> | ||
<div id="myview2"></div> | ||
<div id="myview3"></div> | ||
<script> | ||
SahteReact.store.data = { | ||
counter: { | ||
value: 1 | ||
} | ||
}; | ||
var view1 = new SahteReact({ | ||
template: `<div><span>Counter = {{ counter.value }}</span></div>`, | ||
connect: ['counter'], | ||
target: '#myview1' | ||
}); | ||
var view2 = new SahteReact({ | ||
template: `<div><span>Counter = {{ counter.value }}</span></div>`, | ||
connect: ['counter'], | ||
target: '#myview2' | ||
}); | ||
var view3 = new SahteReact({ | ||
template: `<div><span>View 3 cant access global store's counter.value, because it isn't connected to it</span></div>`, | ||
target: '#myview3' | ||
}); | ||
view1.mount(); | ||
view2.mount(); | ||
view3.mount(); | ||
|
||
// update counter | ||
window.setInterval(function () { | ||
SahteStore.assign({ | ||
counter: { | ||
value: SahteStore.data.counter.value + 1 | ||
} | ||
}); | ||
}, 1000); | ||
</script> | ||
</body> | ||
</html> |