Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing compile method? #21

Open
ChuckJonas opened this issue Jul 14, 2023 · 1 comment
Open

Missing compile method? #21

ChuckJonas opened this issue Jul 14, 2023 · 1 comment

Comments

@ChuckJonas
Copy link

This library seems to only be setup to render view from files. Is there no compile method exposed?

@irustm
Copy link
Member

irustm commented Jul 17, 2023

You can use library Handlebars compiler

example:

import { HandlebarsJS } from 'https://deno.land/x/handlebars/mod.ts';
// or  import HandlebarsJS from "https://esm.sh/handlebars@4.7.7";

function rendering(source: string, context?: Record<string, unknown>, compilerOptions ): Promise<string> {
    // deno-lint-ignore no-explicit-any
    const template = (HandlebarsJS as any).compile(
      source,
      compilerOptions,
    );

    return template(context);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants