标签: sendwithus

如何使用Jinja for循环连接字符串?

我试图迭代地连接一个字符串,用'for'循环构建url params,但我相信我有范围问题.

The output should be: url_param = "&query_param=hello&query_param=world"

array_of_objects = [{'id':'hello'},{'id':'world'}]

{% set url_param = "" %}

{% set array_of_ids = array_of_objects|map(attribute='id')|list%} // correctly returns [1,2]

{% for id in array_of_ids %}
   {% set param = '&query_param='~id %}
   {% set url_param = url_param~param %}                             
{% endfor %}

//url_param is still an empty string
Run Code Online (Sandbox Code Playgroud)

我也尝试过namespace(),但无济于事:

{% set ns = namespace() %}
 {% set ns.output = '' %}
 {% set array_of_ids = array_of_objects|map(attribute='id')|list%} // correctly returns [1,2]
{% for id in …
Run Code Online (Sandbox Code Playgroud)

jinja2 email-templates sendwithus

4
推荐指数
1
解决办法
897
查看次数

GitHub存储库自动加载Composer问题

我有 PHP Fatal error: Class 'sendwithus\sendwithus_php\lib\API' not found

composer.json:

{
    "repositories": {
        "sendwithus_php": {
            "type": "package",
            "package": {
                "name": "sendwithus/sendwithus_php",
                "version": "1.0.3",
                "source": {
                    "url": "https://github.com/sendwithus/sendwithus_php",
                    "type": "git",
                    "reference": "0dfed56"
                }
            }
        }
    },
    "require": {
        "sendwithus/sendwithus_php": ">=1.0.3"
    }, "autoload": {
        "psr-0": {
            "Foo\\": "src/",
            "sendwithus\\": "vendor/sendwithus/sendwithus_php/lib"  
        }
    }, "minimum-stability" : "dev"
}
Run Code Online (Sandbox Code Playgroud)

test.php的:

use sendwithus\sendwithus_php\lib\API;

require_once 'vendor/autoload.php';

$api = new API('KEY');
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

php psr-0 composer-php sendwithus

3
推荐指数
1
解决办法
3834
查看次数

标签 统计

sendwithus ×2

composer-php ×1

email-templates ×1

jinja2 ×1

php ×1

psr-0 ×1