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

How can I render the content without errors? #298

Open
afengsoft opened this issue Feb 25, 2025 · 0 comments
Open

How can I render the content without errors? #298

afengsoft opened this issue Feb 25, 2025 · 0 comments

Comments

@afengsoft
Copy link

afengsoft commented Feb 25, 2025

I want to render HTML in a way that, even if an error occurs, the output still contains as much HTML content as possible. Any unrecognized parts should be output as-is.

If a key is missing or does not exist in the JSON data, {{key}} should output an empty string instead of throwing an error. Otherwise, the error tolerance would be too poor. For example:

nlohmann::json data;
data["name"] = "world";

auto result = inja::render(R"(Guest List:
 ##for guest in guests
    {{ loop.index1 }}: {{ guest }}
 ##endfor )", data);`

I expect the result to be "Guest List:" instead of throwing an exception or stopping execution. The rendering should recognize as much as possible, and any unrecognized parts should be output as-is.

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

1 participant