dtsc1684 2016-05-06 15:35
浏览 303
已采纳

如何从beego AppConfig获取值并将其呈现在HTML模板中?

I want to get value of a key defined in beego's app.conf and render in html pages. As per documentation on http://beego.me/docs/mvc/view/template.md I can get value of AppConfig by using config function in templates. However there is no example in documentation.

Get the value of AppConfig. {{config configType configKey defaultValue}}. configType must be String, Bool, Int, Int64, Float, or DIY

After trying many ways I came to this:

<div>{{config config.String config.appname "TestDefaultValue"}}</div>

But I am always getting error:

<config>: wrong number of args for config: want 3 got 0

What is the correct way to use config template function?

  • 写回答

1条回答 默认 最新

  • dongqiya9552 2016-05-10 03:04
    关注

    Finally I solved this myself. config template function accepts all parameters as string.

    Correct way to use config template function is:

    <div>{{config "String" "appname" "TestDefaultValue"}}</div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services