Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ima-template

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ima-template

A simple template function for generating great-looking code from great-looking TypeScript code.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ima-template

A simple template function for generating great-looking code from great-looking TypeScript code.

Example

Let's say that you want to generate some Java code from a TypeScript tool. You want your source code to look great, but also the generated source code. This is where ima-template can help you!

Given the following example:

import { template } from "ima-template";

function generateCode() {
    return template`
        |class HelloWorld {
        |    public static void main(string[] args) {
        |        System.out.println("Hello world!");
        |    }
        |}
        |`
}

The output of generateCode would look as follows:

class HelloWorld {
    public static void main(string[] args) {
        System.out.println("Hello world!");
    }
}

Features

  • Lines that start with whitespace followed by a pipe (|) are included in the output. Other lines are ignored.
  • The whitespace up to and including the pipe character are not present in the output. This allows you to use proper indentation in the TypeScript code of the code generator, while also having control over the indentation of the generated code.
  • When using a nested template, the indentation is repeated for every line, so that the generated source code makes sense.

Keywords

FAQs

Package last updated on 22 May 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc