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

@dosgato/templating

Package Overview
Dependencies
Maintainers
2
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dosgato/templating - npm Package Compare versions

Comparing version 0.0.85 to 0.0.86

35

dist/component.d.ts

@@ -124,5 +124,5 @@ /// <reference types="node" />

/**
* The second phase of rendering a component is the context phase. This step is TOP-DOWN and
* NON-MUTATING. Each component will receive the parent component's context and then pass a
* NEW context object to its children.
* The second phase of rendering a component is the context phase. This step is TOP-DOWN.
* Each component will receive context from the parent component and then pass a new context
* object to its own children.
*

@@ -133,3 +133,3 @@ * This is useful for rendering logic that is sensitive to where the component exists in

* their children that h4 is next, and so on. (Header level tracking is supported by default in
* dosgato CMS.)
* dosgato CMS - see printHeader() and advanceHeader())
*

@@ -140,4 +140,29 @@ * This function may return a promise in case you need to do something asynchronous based on

*/
setContext(renderCtxFromParent: RenderContextType): RenderContextType | Promise<RenderContextType>;
setContext(renderCtxFromParent: RenderContextType, areaName: string): RenderContextType | Promise<RenderContextType>;
/**
* This function will be provided by the rendering server and should be used inside your fetch
* method to prepare editor-provided HTML for later rendering. It will do things like find and
* resolve link definitions in the internal dosgato format.
*/
fetchRichText: (text: string) => Promise<void>;
/**
* This function will be provided by the rendering server and should be used during the render
* phase to clean up editor-provided HTML. It will do things like clean up tags that were accidentally
* left open to protect overall page integrity, and fix header levels for accessibility.
*
* For instance, an editor supplies a title to be placed above some rich editor content. The
* title uses an <h2>, so the headers inside the rich editor content should start at <h3> and
* should not use <h1> or <h2>.
*
* Setting headerLevel: 3 instructs the renderRichText function to analyze and rebalance the header
* structure of the content so that if it had an h2, it woud be replaced with an h3. Additionally,
* if the user skipped a header level (a WCAG violation) that situation will be repaired as well
* as possible.
*
* If you do not provide a headerLevel, the one from `this.renderCtx` will be used.
*/
renderRichText: (html: string, opts?: {
headerLevel?: number;
}) => string;
/**
* The final phase of rendering a component is the render phase. This step is BOTTOM-UP -

@@ -144,0 +169,0 @@ * components at the bottom of the hierarchy will be rendered first, and the result of the

10

dist/component.js

@@ -76,5 +76,5 @@ import { get, isNotBlank } from 'txstate-utils';

/**
* The second phase of rendering a component is the context phase. This step is TOP-DOWN and
* NON-MUTATING. Each component will receive the parent component's context and then pass a
* NEW context object to its children.
* The second phase of rendering a component is the context phase. This step is TOP-DOWN.
* Each component will receive context from the parent component and then pass a new context
* object to its own children.
*

@@ -85,3 +85,3 @@ * This is useful for rendering logic that is sensitive to where the component exists in

* their children that h4 is next, and so on. (Header level tracking is supported by default in
* dosgato CMS.)
* dosgato CMS - see printHeader() and advanceHeader())
*

@@ -92,3 +92,3 @@ * This function may return a promise in case you need to do something asynchronous based on

*/
setContext(renderCtxFromParent) {
setContext(renderCtxFromParent, areaName) {
return renderCtxFromParent;

@@ -95,0 +95,0 @@ }

import { ContextBase, DataData, PageData, PageRecord, PageRecordOptionalData } from './component.js';
import { AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js';
export declare function printHeader(ctx: ContextBase, content: string | undefined | null, attributes?: Record<string, string>): string;
export declare function advanceHeader(ctx: ContextBase, content: string | undefined | null): {
headerLevel: number;
};
export declare function advanceHeader<T extends ContextBase>(ctx: T, content: string | undefined | null): T;
export interface PictureResize {

@@ -92,9 +90,2 @@ /** the width of this particular resize */

/**
* This function will be provided by the rendering server and should be used inside your fetch
* method to prepare editor-provided HTML for rendering. It will do things like find and resolve
* link definitions in the internal dosgato format and clean up tags that were accidentally left
* open to protect overall page integrity.
*/
processRich: (text: string) => Promise<string>;
/**
* This function will retrieve information about an image to help you construct responsive HTML

@@ -101,0 +92,0 @@ * for a <picture> element including the <img> and all <source> tags.

@@ -1,2 +0,2 @@

import { htmlEncode, isBlank } from 'txstate-utils';
import { htmlEncode, isBlank, isNotEmpty } from 'txstate-utils';
export function printHeader(ctx, content, attributes) {

@@ -6,3 +6,3 @@ if (isBlank(content))

const level = (ctx.headerLevel ?? 0) + 1;
const attr = attributes ? ' ' + Object.entries(attributes).map(([key, val]) => `${key}="${htmlEncode(val)}"`).join(' ') : '';
const attr = isNotEmpty(attributes) ? ' ' + Object.entries(attributes).map(([key, val]) => `${key}="${htmlEncode(val)}"`).join(' ') : '';
if (level < 1)

@@ -15,6 +15,5 @@ return `<h1${attr}>${content}</h1>`;

export function advanceHeader(ctx, content) {
const ret = { ...ctx };
if (!isBlank(content))
ret.headerLevel = (ret.headerLevel ?? 0) + 1;
return ret;
ctx.headerLevel = (ctx.headerLevel ?? 0) + 1;
return ctx;
}
{
"name": "@dosgato/templating",
"version": "0.0.85",
"version": "0.0.86",
"description": "A library to support building templates for dosgato CMS.",

@@ -5,0 +5,0 @@ "type": "module",

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