Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
A unified interface for compiled languages and templates in javascript.
There are two other libraries out there that already do this same thing, consolidate.js and transformers. After looking over and using both of them, I decided to make this one anyway mainly because of maintenance. When creating an interface to many different languages, all of which are constantly changing, you need to be on top of maintenance, testing, and releases. Transformers is not well maintained or tested, which rules it out. Conslidate.js is a little better, but the maintenance at this point is mostly accepting pull requests from people who have changes, rather than actively keeping on top of it. TJ has a lot to do, I understand.
Compiling many different languages is a central component of roots, and it needs a clean, well-managed, and tightly maintained and tested library that adapts to each supported language's interface. We (the maintainers of roots) are not comfortable forking and/or making pull requests into a library that we cannot feel 100% confident in, and so far we have not been able to find one that we are yet. So this is accord, a javascript templating interface you can feel confident in.
npm install accord
Although we are planning a CLI interface which will be awesome, right now accord exposes only a javascript API. Since some templating engines are async and others are not, accord keeps things consistent by returning a promise for any compilation task (using when.js). Here's an example in coffeescript:
fs = require 'fs'
accord = require 'accord'
stylus = accord.load('jade')
# render a string
jade.render('body\n .test')
.catch(console.error.bind(console))
.done(console.log.bind(console))
# or a file
jade.renderFile('./example.jade')
.catch(console.error.bind(console))
.done(console.log.bind(console))
# or precompile a string
# (only a few compilers support precompile right now, see below)
jade.precompile('body\n .test')
.catch(console.error.bind(console))
.done (res) -> console.log(res.toString())
# or a file
jade.precompileFile('./example.jade')
.catch(console.error.bind(console))
.done (res) -> console.log(res.toString())
Docs below should explain the methods executed in the example above.
accord.load(string, object)
- loads the compiler named in the first param, npm package with the name must be installed locally, or the optional second param must be the compiler you are after. The second param allows you to load the compiler from elsewhere or load an alternate version if you want, but be careful.
accord.supports(string)
- quick test to see if accord supports a certain compiler. accepts a string (name of compiler), returns a boolean.
adapter.render(string, options)
- render a stringadapter.renderFile(path, options)
- render a fileadapter.precompile(string, options)
- precompile a string if the adapter has precompile supportadapter.precompileFile(path, options)
- precompile a file if the adapter has precompile supportadapter.extensions
- array of all file extensions the compiler should matchadapter.output
- string, expected output extensionadapter.compiler
- the actual compiler, no adapter wrapper, if you need itAccord can also precompile templates into javascript functions for some languages, which is really useful for client-side rendering. Languages with precompile support are listed below. If you try to precompile a language without support for it, you will get an error.
We are always looking to add precompile support for more languages, but it can be difficult. Any contributions that help to expand this list are greatly appreciated!
Want to add more languages? We have put extra effort into making the adapter pattern structrue understandable and easy to add to and test. Rather than requesting that a language be added, please add a pull request and add it yourself! We are quite responsive and will quickly accept if the implementation is well-tested.
Details on running tests and contributing can be found here
Licensed under MIT
FAQs
A unified interface for compiled languages and templates in JavaScript
The npm package accord receives a total of 77,679 weekly downloads. As such, accord popularity was classified as popular.
We found that accord 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.