Message from JavaScript discussions
July 2017
— I would love to express that sequence some other way that's easier to edit
I need opinions on this syntax... specifically the format
one:
HTML Page:
<template id ="myTemplate">
<div data-content-text="myTag" data-content-text-format="myFormater">
</div>
</template>
<div id="myContainer></div>
JS:
var loader = new cdaTemplate();
loader.addFormatter("myformatter", value => value.toUpperCase());
loader.loadTemplate("#myTemplate", "#myContainer", {
data: {
myTag: "Hello World"
}
});
Result:
<div id="myContainer">
<div>
HELLO WORLD
</div>
</div>
— It's not a lot, but it looks messy
— Check the comments on JSLint
— I wound up scrapping the sequence diagram
— 5 paragraphs of text > that diagram
— I thought so, what do you think is a good way to notate it?
— ¯\_(ツ)_/¯
— Hm, I have a challenge
—
var curData = conf.data;
// Paginate the data
// FIXME: This is completely random as objects are unordered...
if (conf.paged) {
if (!Array.isArray(conf.data)) {
curData = Array.from(conf.data);
}
var pages = Math.ceil(curData.length / conf.elemPerPage);
if (conf.pageNo >= pages) {
curData = curData.slice((conf.pageNo - 1) * conf.elemPerPage, conf.elemPerPage + start);
}
}
— conf.data
is not an Array here, and also that Array.from
will not work on normal objects
— Of course, those were attempts to solve the problem in the FIXME
there