
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
For rendering html element from javascript object using by html template in client-side
For rendering html element from javascript object using by html template in client-side.
$ npm install juel
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="utf-8" />
</head>
<body>
<noscript>Your browser does not support JavaScript!</noscript>
<ul id="changeList"></ul>
<div id="todoList"></div>
<div id="countList"></div>
<ul id="showScope"></ul>
<template juel="todoList">
<ul>Click Items {{ todoList.map(addItem) }}</ul>
</template>
<template juel="todoItem">
<li><button click="{{ click }}">{{ text }}</button></li>
</template>
<script src="./index.build.min.js"></script>
</body>
</html>
const juel = require('juel');
// for update global scope
function changeList(e) {
scope.todoList = [
{ id: 1, text: "Item1", count: 0 },
{ id: 2, text: "Item2", count: 0 },
{ id: 3, text: "Item3", count: 0 },
{ id: 4, text: "Item4", count: 0 },
{ id: 5, text: "Item5", count: 0 }
];
}
// for update sub template element scope
function itemClick(e) {
this.count += 1;
}
// write scope to console
function showScope(e) {
console.log(JSON.stringify(this.toJSON()));
}
// create global scope to apply changes to the DOM
// scope objects created as a global variable are meant to be used in multiple juel
// all juel objects create the scope object if you create the scope
var scope = juel.scope({
todoList: [
{ id: 1, text: "Item1", count: 0 },
{ id: 2, text: "Item2", count: 0 },
{ id: 3, text: "Item3", count: 0 }
]
});
// to read templates written to DOM
juel.template.read();
// single and multiple templates can be added from within the script
juel.template.set('scopeShowBtn', '<button click="{{click}}">Show Scope On Console</button>');
juel.template.set([
{ name: "changeListBtn", html: '<button id="changeListBtn" click="{{ click }}">Change List</button>' },
{ name: "countItem", html: '<li>{{ text }}{{ count ? " - " + count + " Time" + (count > 1 ? "s": "") + " Clicked" : "" }}</li>' },
{ name: "countList", html: '<ul>Clicked Counts {{ todoList.map(addItem) }} NOT: if not clicked, number doesnt show</ul>' }
]);
// add a single template into DOM
juel.append("#changeList", 'changeListBtn', {}, {
click: changeList
});
// multiple sub templates for scope in template can be added to DOM
// the only difference should be create instead of append and output should be HTML
var todoListJuel = juel.append("#todoList", "todoList", scope, {
addItem: function (todoItem) {
return juel.create("todoItem", todoItem, {
click: itemClick.bind(todoItem)
}).toHTML();
}
}).setId("todoList");
// juel.get via setId function to access the juel object
console.log(todoListJuel == juel.get("todoList"));
// you can create more than one juel for the same scope object and change the two juel objects via scope
var countListJuel = juel.append("#countList", "countList", scope, {
addItem: function (todoItem) {
return juel.create("countItem", todoItem).toHTML();
}
}).setId('countList');
// juel.get via setId function to access the juel object
console.log(countListJuel == juel.get("todoList"));
// translate scope object into json type
juel.append('#showScope', 'scopeShowBtn', {}, {
click: showScope.bind(scope)
});
index.build.js file is generated from index.js with libraries like browserify or babel or parcel or webpack.
If you want to write a script without container, write it into the juel tag. During append operation juel disappears.
<template juel="juelTag">
<juel>{{ value }}</juel>
</template>
All notable changes to this project will be documented in this file.
This example shows the most basic way of usage.
This software is free to use under the JosephUz. See the LICENSE file for license text and copyright information.
FAQs
For rendering html element from javascript object using by html template in client-side
The npm package juel receives a total of 3 weekly downloads. As such, juel popularity was classified as not popular.
We found that juel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.