@dosgato/templating 0.0.42 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -92,7 +92,7 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
92
92
  * render will be passed to parent components so that the HTML can be included during the
93
93
  * render of the parent component.
94
94
  */
95
- abstract render(renderedAreas: Map<string, RenderedComponent[]>): string;
95
+ abstract render(): string;
96
96
  /**
97
97
  * Sometimes pages are requested with an alternate extension like .rss or .ics. In these
98
98
  * situations, each component should consider whether it should output anything. For
@@ -105,8 +105,8 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
105
105
  * This function will be run after the fetch phase. The context and html rendering phases
106
106
  * will be skipped.
107
107
  */
108
- renderVariation(extension: string, renderedAreas: Map<string, string>): string;
109
- renderComponents(components?: RenderedComponent[], opts?: {
108
+ renderVariation(extension: string): string;
109
+ renderComponents(components?: RenderedComponent[] | string, opts?: {
110
110
  hideInheritBars?: boolean;
111
111
  }): string;
112
112
  /**
@@ -177,6 +177,7 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
177
177
  path: string;
178
178
  parent?: Component;
179
179
  page?: Page;
180
+ renderedAreas: Map<string, RenderedComponent[]>;
180
181
  hadError: boolean;
181
182
  autoLabel: string;
182
183
  autoNewLabel: string;
@@ -225,7 +226,7 @@ export interface EditBarOpts {
225
226
  }
226
227
  export interface RenderedComponent<C extends Component = Component> {
227
228
  component: C;
228
- html: string;
229
+ output: string;
229
230
  }
230
231
  export declare abstract class Page<DataType extends PageData = any, FetchedType = any, RenderContextType extends ContextBase = any> extends Component<DataType, FetchedType, RenderContextType> {
231
232
  pagePath: string;
package/dist/component.js CHANGED
@@ -79,13 +79,15 @@ export class Component extends ResourceProvider {
79
79
  * This function will be run after the fetch phase. The context and html rendering phases
80
80
  * will be skipped.
81
81
  */
82
- renderVariation(extension, renderedAreas) {
83
- return Array.from(renderedAreas.values()).join('');
82
+ renderVariation(extension) {
83
+ return Array.from(this.renderedAreas.values()).flatMap(ras => ras.map(ra => ra.output)).join('');
84
84
  }
85
85
  // helper function to help you print an area, but you can also override this if you
86
86
  // need to do something advanced like wrap each component in a div
87
87
  renderComponents(components = [], opts) {
88
- return components.flatMap(c => c.component.inheritedFrom && opts?.hideInheritBars ? [c.html] : [c.component.editBar(), c.html]).join('');
88
+ if (!Array.isArray(components))
89
+ components = this.renderedAreas.get(components) ?? [];
90
+ return components.flatMap(c => c.component.inheritedFrom && opts?.hideInheritBars ? [c.output] : [c.component.editBar(), c.output]).join('');
89
91
  }
90
92
  /**
91
93
  * During rendering, each component should determine the CSS blocks that it needs. This may
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {