问题标签 [enlive]
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.
clojure - Enlive:在没有父元素的模板中附加一个片段?
假设我只能访问文件<article>
中的子元素/public/articles.html
。
如何在<article>
不知道父元素的情况下进行迭代?(defsnippet
在 a 中deftemplate
)
我的片段提供了我需要的输出,然后我想将它插入到我的模板中(以及articles.html 其他部分中的其他片段)由于我不了解.clj-article
父元素,我尝试定位它:
我得到了我想要的输出,但是包裹在另一个<article>
和子模式中。
我怎样才能防止这种情况发生?
谢谢!
clojure - 使用enlive提取连续的html片段
我需要抓取具有以下形式的 html:
我需要将标题标签之间的内容作为单独的块获取。所以从一个标题到下一个标题。不幸的是,没有所需范围的容器标签。
我尝试了片段选择器{[:h3] [:h3]}
,但不知何故这只返回所有 h3 标签,它们之间没有标签:
(({:tag :h3, :attrs nil, :content ("Headline1")}) ({:tag :h3, :attrs nil, :content ("Headline2")}) ({:tag :h3, :attrs nil, :content ("Headline3")}))
什么起作用,是{[[:h3 (html/nth-of-type 1)]] [[:h3 (html/nth-of-type 2)]]}
。这给了我第一个和第二个 h3-tag 之间的所有 html。但是,这并不能通过一个选择器为我提供所有所需的块。
可以完全做到这一点,还是我应该求助于正则表达式?
谢谢!
clojure - 如何使用 Clojure Enlive 插入防伪令牌
我尝试使用 ring.util.anti-forgery 将防伪令牌插入 html 表单:
获取异常:
也试过这个:
不工作:(
(anti-forgery-field) 只生成带有一个“输入”的 html 字符串。但我无法将其插入表单。
clojure - 当我使用多个参数时,Compojure 不提供 CSS
我正在尝试使用 Compojure 模仿 Wordpress 永久链接,但是为什么当我使用多个参数时找不到所有静态文件(css、js 和 img)?这是我的代码。
我在浏览器调试控制台中看到 css 是从而http://localhost:3000/2014/11/test/css/main.css
不是http://localhost:3000/css/main.css
. 然后我添加了一条测试路线,并且只使用了这样的参数:
这条路线运行良好。当我访问http://localhost:3000/justfortest
时,所有静态文件都是从根路径提供的。我应该怎么做才能解决这个多参数问题?提前感谢您的回答。
html - Clojure enlive: the function html-content can't operate a function with an argument (?)
So i made a simple html template using deftemplate,
(Note: db/finddata id
is a function that takes a number as a data Id and returns a map of data from my database by a certain data id,
for example if i type
it will produce this
it is a data from my database with an id of 1)
and then
but when i type this in repl
it produces this error
it seems worked just fine with another deftemplate, for example if i change the blogp code
and then i typed this in repl
it worked just fine. Any ideas why?
im new to clojure and im new to enlive as well
json - clojure.data.json 写入/读取影响实时数据
什么是保存和重新加载输出enlive
的适当 json 方式。html-resource
以下过程不保留数据结构(请注意,我要求 json/read-str 将键映射到符号):
谢谢。
更新
为了解决 Mark Fischer 的评论,我发布了一个不同的代码,html/select
而不是html/html-resource
clojure - Enlive - 提取原始 HTML
是否可以使用实时选择器检索原始 HTML(及其怪癖和格式)?
在此示例中,enlive 已将<br>
标签转换为自闭合标签,这与原始输入片段不同。
我怀疑 enlive 正在将其转换为类似打嗝的标签列表,因此不幸的是原始信息丢失了。
clojure - 使用 Enlive/Tagsoup/JSoup 解析 HTML5
HTML5 允许<meta>
标签出现在正文中,但 Enlive 似乎不支持这一点:
此测试失败,但如果您删除元标记,它将通过。
这个旧线程让我意识到这是导致问题的元标记。
我意识到 Enlive 依赖于 Tagsoup,但是当我将其切换为 JSoup(声称支持 HTML5)时,我得到了相同的结果。
clojure - 使用 enlive 在 html 页面上进行多次转换
Clojure 和 enlive 都很棒。在尝试了解 Enlive 的强大功能时,我尝试将两种转换应用于 html 页面。
HTML 页面有 2 个我想要转换的区域(div)。有问题的第一个 div 被克隆了约 16 次。有问题的第二个 div 被克隆了 5 次。原始 div(来自 html 文件)应该被覆盖或根本不出现。
Enlive 有惯用的方法
这对于一次转换非常有效。
但是,我想对页面应用两个转换,所以我尝试了类似的方法:
单独完成的转换完全按照我的意愿进行:它们会占用原始 HTML 并显示我用于填充信息的克隆。
但是,以这种方式一起完成,原始的 html 页面 div 被保留,所以我最终得到了原始 html 文件 div 以及我的克隆,并且这种行为不是 bueno。
请帮忙。
非常感谢。