如何在Liquid中将变量传递到自定义标签中? [英] How to pass a variable into a custom tag in Liquid?

查看:78
本文介绍了如何在Liquid中将变量传递到自定义标签中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在液体中写了一个自定义标签,我想将一个变量传递给它.液体标签会将任何参数转换为字符串.

I have written a custom tag in liquid, and I'd like to pass a variable to it. Liquid tags will turn any parameter into a string.

例如:

{% nav page /some/url.html %}

页面是变量.

有没有办法让Liquid将页面视为变量而不是字符串?

Is there a way to get Liquid to treat page as a variable and not a string?

提前谢谢!

推荐答案

如果专门使用Jekyll,则可以通过以下方式访问页面变量:

If you are using Jekyll specifically, you can access the page variable this way:

def render(context)
  page_url = context.environments.first["page"]["url"]

这篇关于如何在Liquid中将变量传递到自定义标签中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆