问题标签 [hamlet]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
76 浏览

yesod - 所有循环中的 Yesod Hamlet 类型错误令人困惑

我有一个 Yesod 处理程序,它返回 [(Category, [Product])] 类型的列表,我试图在我的 hamlet 模板中循环遍历它。

当我编译时,虽然我收到错误消息:

我不明白为什么它会期待这个以及我能做些什么来让它发挥作用。非常感谢。

更新: 我的处理程序。

0 投票
1 回答
413 浏览

haskell - Yesod accessing a persistent entity id from hamlet

I currently have persistent pulling a list of products from a database and displaying them on the screen. I would like to use the Id from the database to store some information about these products in a cookie and to link to more detailed information pages. From what I understand the ID is only present in the persistent entity and not in the actual Product type? Does this mean that I should store an additional field with a random string that I can use in the cookie or is there a way to access the id used in the database? I will be adding the cookies using JavaScript.

Up until now I have just used PHP and for that I would use the ID. I'm not sure if this is the same in Yesod because of type safety or if there is a best practice way to do this.

0 投票
0 回答
87 浏览

haskell - Hamlet quasiquoter (Haskell):if-elseif-else 表达式中允许的语法

Hamlet quasiquoter 允许 if-then-else 语法,例如

但是,我发现如果我将测试替换为"a" == "b"'a' == 'b'得到一个错误,抱怨“a”是一个非法的变量名。

$if那么or$elseif测试中允许和不允许的语法是什么?我无法在任何地方找到此文档。

0 投票
1 回答
121 浏览

haskell - 如何避免哈姆雷特模板中标签(链接)后的空格?

我找不到一种方法来呈现链接,然后在它之后使用逗号或句号,链接和标点符号之间没有空格。这是我的初步尝试:

或者

这会在单词“here”和“.”之间插入空格。

另一种选择是:

这看起来像是一场胜利,但 HTML 格式不正确:

有没有办法避免链接和标点符号/其他元素之间的空格?

0 投票
1 回答
101 浏览

haskell - 关于 Yesod 小部件相关类型的混淆

我刚开始玩 Yesod,虽然我已经可以得到一些有趣的结果,但我很难清楚地理解它的一些类型(可能是因为我不熟悉 Template Haskell)。

将hamlet 片段传递给 defaultLayout 函数的常用方法是通过 toWidget 函数。因此,按照下面 ham1 和 ham2 的定义,defaultLayout 中的正确指令分别是toWidget ham1ham2

我的问题:在以下(工作)代码中,为什么指令toWidget ham2会编译,而它与 ham1 是完全不同的动物?我猜这意味着 ham1 的类型 ( ham1 :: t -> Text.Blaze.Internal.Markup (*) ) 和 ham2 的类型 ( ham2 :: Widget) 都是 ToWidget 类的实例,但在阅读此类的实例定义时这对我来说并不完全明显。

(*)另外,如果有人能告诉我是否有比t -> Text.Blaze.Internal.Markupham1 更好的类型同义词,那就太好了。

代码:

输出 :

在此处输入图像描述

0 投票
1 回答
740 浏览

templates - Yesod (hamlet) 模板中的注释语法是什么?

我只是找不到如何在 hamlet 模板中注释行。评论有一些语法吗?喜欢

或者其他的东西?

0 投票
2 回答
91 浏览

function - 在 hamlet 文件中调用函数

我写了一个带有函数的小语言查找

现在我想在一个 hamlet 文件中调用这个查找函数。

这可能吗?我如何更改函数以使其可调用?

0 投票
1 回答
155 浏览

haskell - 引入参数后编译 yesod 路由时遇到问题

我正在运行 http://www.yesodweb.com/book/blog-example-advanced的修改示例

以前没有使用 DBEntitySchemaId 类型的参数 id。自从介绍它以来,我得到了

它指的是使用默认布局的行。相关代码为:

我已经尝试过将 whamlet 更改为 hamlet 并从此处添加一些代码行(已注释掉)

尝试使用 hamlet 在 yesod 中发送电子邮件

和改变

以及一些受此启发的变体

使用查询参数呈现 url https://groups.google.com/forum/#!topic/yesodweb/q1gtkOgM32I

我认为只需要做一个小的修改。然而,我对 whamlet/hamlet 的理解并不太好。所以我发布这个以防万一这是一个微不足道的问题。我完全明白我需要做更多的工作,我只是在谷歌上搜索我的问题时遇到了麻烦。所以请多多包涵。

0 投票
1 回答
211 浏览

templates - 如何在 Yesod 中导入莎士比亚模板?

我在 Yesod 中使用 QuasiQuotations,一切正常。但是我的文件变得非常大,不好看。此外,我的 TextEditor 没有正确突出显示此语法。这就是为什么要像这样拆分我的文件:

如果这是错误的,请告诉。这样做runghc myFile.hs会引发许多这样的错误:

和这个。

还有一个HTML(哈姆雷特)。

因此,每个模板一个。

0 投票
0 回答
57 浏览

javascript - 如何使用 YesodWeb 将 Haskell Pandoc 函数绑定到 html 选择器?

我的用例如下:

  • 我有一个使用 YesodWeb 的网站设置
  • 我可以将文本写入一个区域
  • Pandoc 转换我的文本,我在另一个文本框中收到转换后的文本
  • 问题:如何将我的命令绑定到 html 选择器?我需要能够根据选择器向我的 Pandoc 函数提供不同的命令。

我在 my.hs 文件中的函数:

pandoc 命令行是这样的:

(proc "pandoc" ["-f", variable1, "-t", variable2]) 输入“-f”,例如“markup”,输出“-t”,例如“latex”

我在 chat.hamlet(html 模板)中的选择器:

用于输出

用于输入

我写了这个javascript。如何将变量返回到我的 .hs 文件?

conn.send(e.id, e.value)什么都不做。我将如何在服务器端接收消息?

请帮我!