Socket
Socket
Sign inDemoInstall

boxedjs

Package Overview
Dependencies
24
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.2 to 0.4.0

lib/default-config.json

6

index.js

@@ -8,2 +8,3 @@ #!/usr/bin/env node

const packagejson = require('./package.json');
const boxedrc = require('rcfile')('boxed');

@@ -18,3 +19,2 @@

if (program.new) {

@@ -28,6 +28,6 @@ boxed.createNewProject(program.new);

console.log('%s changed.', name);
boxed.compile();
boxed.compile(boxedrc);
});
} else {
boxed.compile();
boxed.compile(boxedrc);
}
const fs = require('fs-extra');
const _ = require('lodash');
const defaultConfig = require('./default-config.json');
module.exports = {
compile: () => {
compile: (boxedrc) => {
const conf = !_.isEmpty(boxedrc)
&& boxedrc.folders ? boxedrc : defaultConfig;
const folders = conf.folders;
let pages = {};
let templates = {};
console.log('Welcome to boxedjs.');
console.log(`Preparing to compile ${conf.name}...`);
console.log('-- Removing old dist/ folder');
fs.removeSync('dist');
fs.mkdir('dist');
fs.removeSync(folders.dist);
fs.mkdir(folders.dist);
console.log('-- Loading pages...');
fs.readdirSync('./pages')
fs.readdirSync(folders.pages)
.filter((item) => {

@@ -19,7 +27,7 @@ return item.indexOf('.html') > -1;

const itemKey = item.substring(0, item.length - 5);
pages[itemKey] = fs.readFileSync(`./pages/${item}`, 'utf8');
pages[itemKey] = fs.readFileSync(`${folders.pages}/${item}`, 'utf8');
});
console.log('-- Loading templates...');
fs.readdirSync('./templates')
fs.readdirSync(folders.templates)
.filter((item) => {

@@ -29,3 +37,3 @@ return item.indexOf('.html') > -1;

const itemKey = item.substring(0, item.length - 5);
templates[itemKey] = fs.readFileSync(`./templates/${item}`, 'utf8');
templates[itemKey] = fs.readFileSync(`${folders.templates}/${item}`, 'utf8');
});

@@ -40,3 +48,3 @@

});
fs.writeFile(`dist/${pageKey}.html`, templatedPage, (err) => {
fs.writeFile(`${folders.dist}/${pageKey}.html`, templatedPage, (err) => {
if (err) {

@@ -49,5 +57,5 @@ console.log(err);

if (fs.pathExistsSync('assets')) {
if (fs.pathExistsSync(folders.assets)) {
console.log('-- Copying asset folder');
fs.copySync('assets', 'dist');
fs.copySync(folders.assets, folders.dist);
}

@@ -54,0 +62,0 @@

{
"name": "boxedjs",
"version": "0.3.2",
"version": "0.4.0",
"description": "A simple static HTML templating engine.",

@@ -36,3 +36,5 @@ "main": "index.js",

"fs-extra": "^4.0.1",
"node-watch": "^0.5.5"
"lodash": "^4.17.4",
"node-watch": "^0.5.5",
"rcfile": "^1.0.3"
},

@@ -39,0 +41,0 @@ "devDependencies": {

@@ -39,11 +39,30 @@ # boxedjs

/
├── assets/
├── pages/
├── templates/
├── src/
├── assets/
├── pages/
├── templates/
├── .boxedrc
```
where the content of the folders is the following:
- `assets`: contains all the styling files, images and other files but html.
- `pages`: contains the pages of your website
- `templates`: contains the templates used inside the `pages`
- `src/assets`: contains all the styling files, images and other files but html.
- `src/pages`: contains the pages of your website
- `src/templates`: contains the templates used inside the `pages`
### .boxedrc
This file contains the configuration for the project.
By default it has the following content:
```json
{
"name": "Untitled project", \\ name of the project
"folders": {
"pages": "src/pages", \\ location containing the pages
"templates": "src/templates", \\ location containing the templates
"assets": "src/assets", \\ location containing the assets
"dist": "dist" \\ export directory (where your compiled website will be)
}
}
```
Feel free to customise it to suit your project structure better.
### How to use the templates in a page

@@ -50,0 +69,0 @@ Whenever you want to use one of the `templates` in one of the `pages` you can require them like the following:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc