Socket
Book a DemoInstallSign in
Socket

closure-templates-compiler

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

closure-templates-compiler

1.0.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

closure-templates-compiler

Simple javascript module that uses java-bridge under the hood to compile a string written in google closure templates language to javascript.

It also contains a small java project (which is published as a jar), because the compiler for google closure templates is written in java. The java is just a wrapper to invoke the API of the closure templates compiler directly rather than use the CLI version.

Getting started

npm install --save closure-templates-compiler

API

import { compileSoyToJs, compileSoyToJsSync } from "closure-templates-compiler";

const soyCode = `
{namespace soy.examples.simple}

{template helloWorld}
  {msg desc="Says hello to the world."}
    Hello world!
  {/msg}
{/template}
`;

const filename = "foobar.soy";

const jsCodeString = await compileSoyToJs(soyCode, filename);

const jsCodeStringAlternate = compileSoyToJsSync(soyCode, filename);

Example:

In:

{namespace soy.examples.simple}

{template helloWorld}
  {msg desc="Says hello to the world."}
    Hello world!
  {/msg}
{/template}

Out:

goog.provide('soy.examples.simple');
goog.require('goog.soy');
goog.requireType('goog.soy.data.SanitizedHtml');
goog.require('soy');

soy.examples.simple.helloWorld = function (opt_data, opt_ijData) {
  const $ijData =opt_ijData;
  if (goog.soy.shouldStub && goog.soy.shouldStubAtRuntime() && soy.examples.simple.helloWorld_soyInternalStubs) {
    return soy.examples.simple.helloWorld_soyInternalStubs(opt_data, $ijData);
  }
  if (goog.DEBUG && soy.$$stubsMap['soy.examples.simple.helloWorld']) {
    return soy.$$stubsMap['soy.examples.simple.helloWorld'](opt_data, $ijData);
  }
  return soy.VERY_UNSAFE.ordainSanitizedHtml('Hello world!');
};
if (false) {
  soy.examples.simple.helloWorld_soyInternalStubs;
}
if (goog.DEBUG) {
  soy.examples.simple.helloWorld.soyTemplateName = 'soy.examples.simple.helloWorld';
}

Keywords

google

FAQs

Package last updated on 20 May 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.