npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tsomaiatech/moxite

v1.0.5

Published

Moxite template language

Readme

Moxite Template Engine

Moxite is a fast, structural, and strictly evaluated template engine designed to enforce a clear separation between application logic and the presentation layer.

Moxite approaches template parsing through a dedicated, character-by-character Lexer and a recursive descent Abstract Syntax Tree (AST) Parser, moving away from string-replacement or Regex-heavy architectures.

By evaluating an isolated AST, Moxite cleanly scopes template logic and ensures high reliability when parsing complex, overlapping data structures.

Design Philosophy

The core philosophy of Moxite is to keep templates simple and focused purely on rendering:

  1. Explicit Lexing: Every template token is mapped through an atomic Lexical State machine and evaluated via a recursive descent Parser, ensuring predictable boundaries even when templates overlap with other syntaxes like JSON, bash scripts, or nested code blocks.
  2. Strict Expression Evaluation: The expression parser deliberately limits complex inline operations. Features like inline array definitions [1, 2] or JSON closures {key: val} are intentionally unsupported, encouraging developers to construct their data payloads cleanly in the upstream application code.
  3. Implicit Safe Navigation: The engine automatically protects against null or undefined property access without throwing verbose errors. For example, {{ user.profile.name }} is implicitly handled as user?.profile?.name under the hood.

Syntax Outline

Interpolation & Implicit Chaining

Hello, {{ user.name }}!
Implicit Safe Output: {{ user.deep.missing.path.shouldNotCrash }}

Conditionals (@if)

@if (user.isAdmin)
  Welcome Administrator.
@else if (user.isGuest === "yes")
  Welcome Guest.
@else
  Welcome User.
@endif

Loops (@for)

@for (item of items)
  Item: {{ item.name }}
@else
  No items found.
@endfor

Moxite supports an optional @else fallback inside @for loops, which executes automatically if the iterable is empty or undefined.

Additionally, Loop Metadata is injected into the scope for every iteration, allowing you to access:

  • {{ $index }} (0-based iteration index)
  • {{ $first }} (boolean)
  • {{ $last }} (boolean)
  • {{ $count }} (total length of the array)

Block Scoping (@const)

@const greeting = "Hello"
@const role = user.role

{{ greeting }}, you are a {{ role }}

Pipes (|)

Pipes allow you to pass variables through formatting functions registered in your evaluation context.

{{ user.name | upper }}
{{ total | currency: "USD" }}

Components & Hoisting (@template / @use)

Moxite supports creating reusable local template blocks. Template definitions are hoisted, meaning you can @use them before defining them in the file:

@for (user of users)
  {{ @use card with { user } }}
@endfor

@template card({ user })
  <div class="card">{{ user.name }}</div>
@endtemplate

Raw Blocks (@raw)

Content inside a @raw block is completely ignored by the parser and output exactly as-is. Useful for emitting strings like {{ or @ that would otherwise trigger the template engine.

@raw
{{ this.will.not.be.parsed }}
@endraw

Clean Output (Whitespace Stripping)

Moxite automatically trims structural whitespace. When you write structural tags like @if, @for, or @const on their own lines, Moxite will strip the indentation and trailing newlines so that the final output remains perfectly clean, without injecting empty blank lines everywhere. Content inside standard text blocks remains entirely unmodified.

Structure

  • src/: Contains the pure TypeScript reference implementation of the strict Lexer, AST Parser, and Evaluator (template-engine.ts).
  • idea-plugin/: A Gradle project containing the IntelliJ IDEA plugin. Powered by Grammar-Kit and JFlex, this plugin provides native JetBrains syntax highlighting, completion, and semantic validation for .mx files using the exact same DFA token boundaries as the TypeScript engine.