Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json IronRouter pathFor-从模板助手传递参数_Json_Meteor_Iron Router - Fatal编程技术网

Json IronRouter pathFor-从模板助手传递参数

Json IronRouter pathFor-从模板助手传递参数,json,meteor,iron-router,Json,Meteor,Iron Router,我在我的项目中使用IronRouter,它有不同语言的内容。为了显示消息代码,我使用了UI.registerHelper,如下所示: UI.registerHelper('loadMessageCode', function(message) { //Logic in here to load string inside a template return 'sample-string-in-a-language'; }); <a href="{{pathFor 'con

我在我的项目中使用IronRouter,它有不同语言的内容。为了显示消息代码,我使用了UI.registerHelper,如下所示:

UI.registerHelper('loadMessageCode', function(message) {
    //Logic in here to load string inside a template
    return 'sample-string-in-a-language';
});
<a href="{{pathFor 'content' _page_slug=this.slug}}" title="{{title}}">
    {{title}}
</a>
我的内容是从json文件加载的,字符串用不同的语言指定,如下所示。当应用程序启动时,会将其添加到Mongo.Collection中

{
    "name": "Pages",
    "items": [
        {
            "title": {
                "en": "About Us",
                "de": "Über"
            },
            "slug": {
                "en": "about",
                "de": "über"
            },
            "content": {
                "en": "......"
                "de": "......"
            }

        }
    ]
}
当从我的模板中为我的内容生成链接时,我使用的是IronRouters pathFor函数,我以前使用过该函数来生成链接。其工作如下:

UI.registerHelper('loadMessageCode', function(message) {
    //Logic in here to load string inside a template
    return 'sample-string-in-a-language';
});
<a href="{{pathFor 'content' _page_slug=this.slug}}" title="{{title}}">
    {{title}}
</a>
在我重构Json文件的结构之前,它工作得很好。现在我想做的是以下几点:

<a href="{{pathFor 'content' _page_slug=<Use my helper function to dig out the slug>}}" title="{{title}}">
    {{title}}
</a>

我的问题是,这可以做到吗?如果可以,如何做到

流星0.9.x的说明

在模板中创建其他辅助对象:

JS

HTML


谢谢你的回答。与在模板中再次调用UI帮助函数相比,能够直接调用UI帮助函数是非常理想的,但是有了这一点,您的解决方案工作得非常好,再次感谢。