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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

html static webpages #34

Closed
May4m opened this issue Dec 1, 2020 · 4 comments
Closed

html static webpages #34

May4m opened this issue Dec 1, 2020 · 4 comments

Comments

@May4m
Copy link

May4m commented Dec 1, 2020

Hi Pim. Thanks for putting time on Falco. I'm new to both F# and Falco and I'm learning through creating stuff 馃檪 . One question I have is how do I render .html static files and edit the attributes and elements/nodes in Falco or something like template rendering.

@pimbrouwers
Copy link
Owner

Hi Sizwe,

Thanks for reaching out.

I'm unsure what you're trying to do exactly. Are you trying to produce an HTML response? Or physically read an HTML file from disk, and render it's contents?

@May4m
Copy link
Author

May4m commented Dec 1, 2020

I'm trying to read html file from disk, modify and render the contents

@pimbrouwers
Copy link
Owner

pimbrouwers commented Dec 1, 2020

Thank you for the clarification!

The Falco view engine won't help you with this, since it's based on pure F# functions. To me, it sounds like you need a template engine like scriban, which will efficiently replace symbols found in string literals.

You can use the string you get from scriban, or another template engine with the Response.ofHtmlString in order to render the HTML with Falco.

let htmlStringHandler : HttpHandler =
    let html = "{html string from template engine}"
   
    html
    |> Response.ofHtmlString

For a complete example of how this works, checkout the scriban example in the sample projects directory.

@May4m
Copy link
Author

May4m commented Dec 2, 2020

thanks, scriban sounds like exactly like what i need :). I'm closing the issue

@May4m May4m closed this as completed Dec 2, 2020
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