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

@memberjunction/templates-base-types

v5.20.0

Published

MemberJunction Templating Base Types for Client/Server Use

Downloads

20,531

Readme

@memberjunction/templates-base-types

Base types and metadata caching engine for MemberJunction's templating system. Provides cached access to template metadata and can be used on both client and server.

Architecture

graph TD
    subgraph "@memberjunction/templates-base-types"
        A[TemplateEngineBase] --> B[Templates Cache]
        A --> C[Template Contents]
        A --> D[Template Params]
        A --> E[Content Types]
        A --> F[Categories]
    end

    subgraph "Loaded via Dataset"
        G["Template_Metadata<br/>Dataset"]
    end

    G --> A

    H["@memberjunction/templates<br/>(Server Engine)"] --> A

    style A fill:#2d6a9f,stroke:#1a4971,color:#fff
    style B fill:#2d8659,stroke:#1a5c3a,color:#fff
    style C fill:#2d8659,stroke:#1a5c3a,color:#fff
    style D fill:#2d8659,stroke:#1a5c3a,color:#fff
    style E fill:#7c5295,stroke:#563a6b,color:#fff
    style F fill:#7c5295,stroke:#563a6b,color:#fff
    style H fill:#b8762f,stroke:#8a5722,color:#fff

Overview

This package provides the foundational layer for MemberJunction's templating system:

  • TemplateEngineBase: Singleton engine that loads and caches all template metadata via the Template_Metadata dataset
  • TemplateRenderResult: Standard result type for template rendering operations
  • Metadata Access: Cached getters for templates, content types, categories, contents, and params
  • Template Lookup: Convenience method for finding templates by name (case-insensitive)
  • Content Association: Automatically associates template contents and params with their parent templates after loading

Installation

npm install @memberjunction/templates-base-types

Usage

Initializing the Engine

import { TemplateEngineBase } from '@memberjunction/templates-base-types';

// Load template metadata
await TemplateEngineBase.Instance.Config(false, contextUser);

// Force refresh
await TemplateEngineBase.Instance.Config(true, contextUser);

Accessing Template Metadata

const engine = TemplateEngineBase.Instance;

// All templates (with Content and Params pre-associated)
const templates = engine.Templates;

// Find a template by name
const emailTemplate = engine.FindTemplate('Welcome Email');

// Access template contents and params
const contents = emailTemplate.Content;
const params = emailTemplate.Params;

// Other metadata
const contentTypes = engine.TemplateContentTypes;
const categories = engine.TemplateCategories;

TemplateRenderResult

import { TemplateRenderResult } from '@memberjunction/templates-base-types';

// Returned by rendering operations
const result: TemplateRenderResult = {
    Success: true,
    Output: '<html>...</html>',
    Message: undefined  // Only set on failure
};

API Reference

TemplateEngineBase

| Member | Type | Description | |--------|------|-------------| | Instance | static getter | Singleton instance | | Config() | method | Load/refresh template metadata | | Templates | getter | All templates with associated contents and params | | TemplateContentTypes | getter | Available content types | | TemplateCategories | getter | Template categories | | TemplateContents | getter | All template content records | | TemplateParams | getter | All template parameter definitions | | FindTemplate() | method | Find template by name (case-insensitive) |

TemplateRenderResult

| Property | Type | Description | |----------|------|-------------| | Success | boolean | Whether rendering succeeded | | Output | string | The rendered output | | Message | string (optional) | Error message on failure |

Relationship to @memberjunction/templates

This package provides the metadata caching layer usable anywhere. The @memberjunction/templates package extends it with server-side Nunjucks rendering, custom extensions, and AI prompt integration.

graph LR
    A["@memberjunction/templates-base-types<br/>(Metadata + Types)"] --> B["@memberjunction/templates<br/>(Server Rendering)"]
    C[Client Code] --> A
    D[Server Code] --> B

    style A fill:#2d6a9f,stroke:#1a4971,color:#fff
    style B fill:#2d8659,stroke:#1a5c3a,color:#fff
    style C fill:#b8762f,stroke:#8a5722,color:#fff
    style D fill:#b8762f,stroke:#8a5722,color:#fff

Dependencies

| Package | Purpose | |---------|---------| | @memberjunction/core | BaseEngine, UserInfo, IMetadataProvider | | @memberjunction/core-entities | Template entity types | | @memberjunction/global | MJGlobal class factory |

License

ISC