Socket
Socket
Sign inDemoInstall

gluex

Package Overview
Dependencies
104
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gluex

a tool to glue all of your stuff together


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

gluex

glue your stuff together

GLUEX is a tool to glue multiple HTML, JavaScript or JSON files (or other file types) together. It lets you use selectors to only pick a certain tag from a HTML document or a certain property from a JSON. Furthermore it allows the usage of namespaces, for example to distinguish between a development and a productive scenario. It could be used as a CLI tool as well as a module in your code.

Installation

as a command line tool

npm install gluex -g

as a module

npm install gluex --save

Usage

GLUEX uses inline comment-based directives to determine which files you'd like to glue.

In a JavaScript file

// @gluex path/to/file.js

or

/* @gluex path/to/file.js */

In a HTML file

<!-- @gluex path/to/file.html -->

invoke as a CLI tool

to glue just once:

gluex -i path/to/input.xx -o path/to/output.xx

to watch files for changes:

gluex -i path/to/input.xx -o path/to/output.xx -w

When watching, GLUEX will automatically watch any referenced files for changes too, and recompile the output file upon any changes to reference files.

invoke as a module

var gluex = require("gluex"),

inputPath = "path/to/input.xx",
outputPath = "path/to/output.xx",
namespace = null,
watch = true,

gluex(inputPath, outputPath, namespace, watch);

if you omit the outputPath the glued file gets returned by the function like so...

var output = gluex(inputPath);

Advanced Usage

Namespaces

<body>
<!-- gluex path/to/dev_only.html -->
<!-- gluex:production path/to/prod.html -->
</body>

When calling gluex with the namespace production the first directive will be replaced with an empty string (deleted) and only the second one will be replaced with the content of the refernced file. Calling with no namespace will replace both comments and remove none. This works the same for JS. You can pass a namespace like so:

CLI
gluex -i path/to/input.xx -o path/to/output.xx -n production
Module
gluex('path/to/input.xx', 'path/to/output.xx', 'production');

Selectors

<head>
    <title><!-- gluex path/to/package.json (.name) --></title>
</head>
<body>
<!-- gluex path/to/partials.html (#someID) -->
</body>

For JSON and HTML includes you can put a selectors behind the filename (in brackets). For a JSON file the selector has to be a property path. For a HTML file you can use any CSS selector.

License

MIT License

Copyright (c) 2017 Stefan Keim (indus)

Keywords

FAQs

Last updated on 31 May 2017

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.

Install

Related posts

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