Trouble Evaluating Effects with `Template` in `@effect/platform`

QQ: Trying to work with Template in @effect/platform. I can't seem to get the Effects to evaluate like the tests show. Am I missing something?

const getComponent = (componentName: string) =>
  Effect.gen(function* () {
    if (rawComponentMap.has(componentName)) {
      return yield* Template.make`${rawComponentMap.get(componentName)}`;
    }
    const fs = yield* FileSystem.FileSystem;
    const componentTemplate = yield* fs
      .readFileString(`src/server/components/${componentName}.html`, "utf8")
      .pipe(
        Effect.catchAll(() =>
          Effect.gen(function* () {
            yield* Effect.logError(
              `Cannot find template file for component: ${componentName}`
            );
          })
        )
      );

    if (componentTemplate) {
      rawComponentMap.set(componentName, componentTemplate);
    }
    const rawComponent = rawComponentMap.get(componentName);
    if (!rawComponent) return null;
    return yield* Template.make`${rawComponent}`;
  }).pipe(Effect.provide(NodeFileSystem.layer));
Was this page helpful?