简体   繁体   English

如何将简单的Haskell变量传递给Heist模板?

[英]How do I pass simple Haskell variables to a Heist template?

First off, I'm very new to Snap and Heist :) 首先,我是Snap和Heist的新手:)

In all templating engines that I have used, there is always a way to pass a variable from the render function to the template. 在我使用的所有模板引擎中,总有一种方法可以将变量从render函数传递到模板。 The template can then display the variable in its place. 然后,模板可以在其位置显示变量。 Now, I do understand that Heist is particularly strict, but I'm not even trying to do a loop or an if/else here, just display a random number. 现在,我的确知道Heist的要求特别严格,但是我什至不尝试在此处进行循环或if / else,仅显示一个随机数。 I imagine this is a pretty basic thing, but I haven't found anything in the docs that shows how this can be done without using splices. 我想这是一件很基本的事情,但是我没有在文档中找到任何可以显示不使用接头即可完成此操作的东西。

So in short, is it possible to have a Snap handler that generates a number, then passes it to a Heist template to render, without using splices? 简而言之,是否有可能使用Snap处理程序来生成数字,然后将其传递给Heist模板以进行渲染,而无需使用接头? If yes, please give me some example code, if no, please show me the simplest way it can be done. 如果是,请给我一些示例代码,如果否,请给我展示最简单的方法。

Splices are the way that you pass Haskell information to a template. 拼接是将Haskell信息传递到模板的方式。 That's the way you have to do it. 那就是你要做的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM