onpopstate
- ловите событие "возврата назад" и делаете ajax по актуальному урлу -> меняете контент pug index.pug -P
-V, --version output the version number
-O, --obj <str|path> JSON/JavaScript options object or file
-o, --out <dir> output the rendered HTML or compiled JavaScript to <dir>
-p, --path <path> filename used to resolve includes
-b, --basedir <path> path used as root directory to resolve absolute includes
-P, --pretty compile pretty HTML output
-c, --client compile function for client-side
-n, --name <str> the name of the compiled template (requires --client)
-D, --no-debug compile without debugging (smaller functions)
-w, --watch watch files for changes and automatically re-render
-E, --extension <ext> specify the output file extension
-s, --silent do not output logs
const serialize = (form) => {
const obj = {};
const inputs = [...form.querySelectorAll('input')];
inputs.forEach((input) => {
const params = input.name.match(/(?<=\[)\S+?(?=\])|^\S+?(?=\[)/g);
const value = input.value;
params.reduce((current, param, i, arr) => {
if (!obj[param]) current[param] = {};
if (i === arr.length - 1) current[param] = value;
return current[param];
}, obj);
});
return obj;
};
JSON.parse('');
JSON.parse(data)
каждый раз, но т.к. данный скрипт падает ошибкой, срабатывает error callback