MCPcopy Index your code
hub / github.com/Squarespace/template-compiler

github.com/Squarespace/template-compiler @2.11.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.11.1 ↗ · + Follow
2,413 symbols 9,633 edges 225 files 508 documented · 21% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Squarespace Template Compiler.

A Java template compiler based on JSON-Template.

Build Status Coverage Status

License: Apache 2.0 (summary)

Copyright (c) 2014 SQUARESPACE, Inc.

Overview

Squarespace's template language is based on JSON-Template, a minimal declarative template language for Python and JavaScript, heavily influenced by google-ctemplate.

Objectives

The project was started with these objectives:

  • Move away from using Node.js for backend template compilation.
  • Must meet or exceed performance of the legacy system. The compiler can potentially execute several times for each page view, so it needs to be really fast.
  • Improve performance over the legacy system.
  • Minimize memory usage. For example, parsing can often create and discard a high number of temporary strings.
  • Support additional features for server-side compilation.
  • High test coverage.
  • Support syntax error recovery.
  • Support a template validation mode.

Measured Results

  • Average 20x performance increase over previous Node.js + JSON-Template system.

Extension points exported contracts — how you extend this code

FormatterRegistry (Interface)
Registers formatter implementations into a symbol table. [14 implementers]
core/src/main/java/com/squarespace/template/FormatterRegistry.java
CodeSink (Interface)
Interface for classes which accept lists of instructions. [6 implementers]
core/src/main/java/com/squarespace/template/CodeSink.java
PredicateRegistry (Interface)
Registers predicate implementations into a symbol table. [16 implementers]
core/src/main/java/com/squarespace/template/PredicateRegistry.java
FunctionDef (Interface)
Interface implemented by expression functions. [118 implementers]
core/src/main/java/com/squarespace/template/expr/FunctionDef.java
TestCase (Interface)
(no doc) [7 implementers]
core/src/test/java/com/squarespace/template/TestCaseParser.java

Core symbols most depended-on inside this repo

append
called by 534
core/src/main/java/com/squarespace/template/v8dtoa/FastDtoaBuilder.java
get
called by 278
core/src/main/java/com/squarespace/template/Variables.java
add
called by 262
core/src/main/java/com/squarespace/template/Block.java
path
called by 237
core/src/main/java/com/squarespace/template/TokenMatcher.java
put
called by 182
core/src/main/java/com/squarespace/template/MapBuilder.java
eof
called by 178
core/src/main/java/com/squarespace/template/CodeMaker.java
args
called by 137
core/src/main/java/com/squarespace/template/CodeMaker.java
first
called by 122
core/src/main/java/com/squarespace/template/Variables.java

Shape

Method 2,009
Class 365
Interface 20
Enum 19

Languages

Java100%

Modules by API surface

core/src/main/java/com/squarespace/template/Instructions.java194 symbols
core/src/main/java/com/squarespace/template/plugins/CoreFormatters.java113 symbols
core/src/main/java/com/squarespace/template/plugins/platform/CommerceFormatters.java91 symbols
core/src/main/java/com/squarespace/template/plugins/platform/ContentFormatters.java84 symbols
core/src/main/java/com/squarespace/template/match/Recognizers.java66 symbols
core/src/main/java/com/squarespace/template/Context.java55 symbols
core/src/test/java/com/squarespace/template/expr/ExprTest.java48 symbols
core/src/test/java/com/squarespace/template/plugins/CoreFormattersTest.java47 symbols
core/src/main/java/com/squarespace/template/CodeMaker.java38 symbols
core/src/main/java/com/squarespace/template/plugins/platform/SocialFormatters.java34 symbols
core/src/main/java/com/squarespace/template/TokenMatcher.java32 symbols
core/src/test/java/com/squarespace/template/TokenizerCoreTest.java29 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add template-compiler \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact