Socket
Socket
Sign inDemoInstall

@diotoborg/placeat-ea-autem

Package Overview
Dependencies
103
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @diotoborg/placeat-ea-autem

A template parser in Node.js that supports replacers and functions. Allows users to use custom outputs and access functions and variables in a custom template file.


Version published
Weekly downloads
206
decreased by-43.87%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Termfx JS

A template parser in Node.js that supports replacers and functions. Allows users to use custom outputs and access functions and variables in a custom template file.

npm version install size

Table of contents:

Installation

npm install @diotoborg/placeat-ea-autem

Usage

Note: An update has been planned to remove the need to explicitly declare if the file is CRLF or LF break files!

const @diotoborg/placeat-ea-autem = require('@diotoborg/placeat-ea-autem');

New() is the main class, create a new instance of this! The instance of @diotoborg/placeat-ea-autem has three main functions, two of them registering variables and functions, the third being the executer.

RegisterVariable - Takes in two strings, the first is the replacer(or tag) and the second is the "to be replaced". RegisterFunction - Takes in a string and a function, the first one being the tag, the second one being the function that can be executed.

Execute - Takes a string and writer(a function/method), the string template is parsed. Any regular strings that are not variable/function tags will be executed by the writer. Variable tags will be replaced and functions will be executed with respect to the parameters that were provided in the string template.

Examples:

const @diotoborg/placeat-ea-autem = require('@diotoborg/placeat-ea-autem');
var registry = new @diotoborg/placeat-ea-autem.New();

registry.RegisterVariable("foo", "bar");
registry.RegisterFunction("sleep",
  function(delayInms){
    return new Promise(resolve => setTimeout(resolve, delayInms));
  }
);

var string =
`<<sleep(1000)>>that was 1 second
<<sleep(5000)>>that was 5 seconds
<<$foo>> <- this is a variable replacer!`;

Carriage Return Line Feed Files

Also known as CRLF, this is what most files @diotoborg/placeat-ea-autem is supposedly parsing, files are expected to have \r\n at the end of each line. This mode will not add a carriage return \r at the end of each line.

const @diotoborg/placeat-ea-autem = require('@diotoborg/placeat-ea-autem');
var registry = new @diotoborg/placeat-ea-autem.New();

Line feed

Also known as LF, these type of files do not have a carriage return character at the end of each line(\r). A \r character will be added to the end of every line. This is used to handle the issue where everything is output in 1 line by the writer.

const @diotoborg/placeat-ea-autem = require('@diotoborg/placeat-ea-autem');
var registry = new @diotoborg/placeat-ea-autem.New(null, true);

Custom splitter

Using a custom splitter that isn't the default <<, >>.

// custom splitter
const @diotoborg/placeat-ea-autem = require('@diotoborg/placeat-ea-autem');
var registry = new @diotoborg/placeat-ea-autem.New(["[[", "]]"], true);
// E.g. This will now allow you to use [[$tag]] instead of <<$tag>>

Bugs or suggestions

  • Please report any bugs or provide suggestions in the github!

License

Copyright Apache 2.0 License © 2022 Jeffplays2005.

Keywords

FAQs

Last updated on 12 Jun 2024

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