Working JS Template Engine with basic functionality

This commit is contained in:
2025-06-20 17:05:51 +10:00
parent fac560750e
commit ee7762d69b
11 changed files with 371 additions and 25 deletions

23
public/js/template.js vendored Normal file
View File

@@ -0,0 +1,23 @@
/* JavaScript template engine abstraction layer */
/* Currently implemented for jquery */
// Get a value from an attribute
function get_attribute(attribute,start,end) {
var val = $('#'+attribute).find('input').val();
return ((start !== undefined) && (end !== undefined))
? val.substring(start,end)
: val;
}
// Put a value to an attribute
function put_attribute(attribute,result) {
// Get the value, if the value hasnt changed, then we dont need to do anything
if (get_attribute(attribute) === result)
return;
$('#'+attribute)
.find('input')
.val(result)
.trigger('change');
}