Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
P portal
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Create a new issue
  • Jobs
  • Issue Boards
Collapse sidebar
  • 科探开源
  • portal
  • Wiki
    • 数据管理手册
  • 094.Views twig 配置

Last edited by asdu Dec 21, 2020
Page history

094.Views twig 配置

1.Views twig 配置

  1. 常规函数,参考文档 https://twig.symfony.com/doc/3.x/
  2. 支持token
{{  value |portal_callback("funName")}}  和 {{  value | portal_token }} 

1.1常规函数实体

具体请参考文档 https://twig.symfony.com/doc/3.x/ 函数 | 结果 ---|--- {{"now"|date("Y-m-d h:i:s")}} | 2020-08-05 04:30:08 {{ 'welcome'|upper }} | WELCOME

1.2支持token

格式: token标识符|portal_token
函数 结果
{{"[current-user:name]" |portal_token}} 20180201 (备注:返回职工号)
{{"[api:svc:pm.parser::md5(201198832)]" |portal_token}} 472e61fde92RRfc64370e8a728

特殊说明:

  • 如何传入变量,比如上面的例子“201198832”这个是变量。
  • token_str1,$token_str2 是字符串组成token标识符
  • nothing 是变量值要传入到token里的,相当与201198832值。在views就是字段名称
{% set token_st1 = '[api:svc:pm.parser::md5(' %}
{% set token_str2 = ')]' %}
{{ (token_st1  ~ nothing ~ token_st2) | portal_token }}

1.3 支持调用php常规函数

格式: 传入php函数值|portal_callback(php函数名)

是对twig的扩张补充

函数 结果
{{ "139982"|portal_callback("md5")}} 472e61fde92RRfc64370e8a728
{{ "welcome" |portal_callback("strtoupper")}} WELCOME

1.4额外例子

{% set str1 = nothing |portal_callback("md5") %}
{% set str2 = "hwww" |portal_callback("strtoupper") %}
{{ str1 ~ str2}}

结果

472e61fde937e2d8762fc64370e8a728HWWW
Clone repository
  • Home
  • 数据管理手册
    • 094.Views twig 配置
    • ETL01.数据管理使用手册 V2.0
    • ETL02.Source 数据请求 data_fetcher_plugin
    • ETL03.Source 解析 data_parser_plugin
    • ETL04.Source 认证插件 authentication
    • ETL05.Porcess plugins 明细
    • ETL06.URL endpoint 数据管理E
    • ETL07.Mysql 数据管理
    • ETL08.MSSQL 数据管理
    • ETL09.Oracle 数据管理
    • ETL10.Token 列表
  • 门户V2 API 文档
    • 01.Portal Rest API v2
    • 01.Resource API
    • 02.App API
View All Pages