我正在将Stripe API与CMS 集成.我需要将_values查询中的属性作为数组返回,以便数据在CMS中作为模板变量可用,但它始终受到保护.
我一直在使用Reflection类来获取数据,但是现在我正在使用Stripe \Stripe\Plan::all();,我必须调用我编写的快捷方法来多次处理Reflection类.但它并不完全是递归的,因为我必须根据我从Stripe API调用的方法来区别对待它.
有没有办法真正递归地使用Reflection类?是否有一些比我不知道的反射类更合适的东西?
这是一个示例var_dump()ed响应\Stripe\Plan::all();:
object(Stripe\Collection)#604 (5) {
["_opts":protected]=>
object(Stripe\Util\RequestOptions)#603 (2) {
["headers"]=>
array(0) {
}
["apiKey"]=>
string(32) "XXXXXXXXXXXXXXXX"
}
["_values":protected]=>
array(4) {
["object"]=>
string(4) "list"
["has_more"]=>
bool(false)
["url"]=>
string(9) "/v1/plans"
["data"]=>
array(2) {
[0]=>
object(Stripe\Plan)#605 (5) {
["_opts":protected]=>
object(Stripe\Util\RequestOptions)#603 (2) {
["headers"]=>
array(0) {
}
["apiKey"]=>
string(32) "XXXXXXXXXXXXXXXX"
}
["_values":protected]=>
array(12) {
["id"]=>
string(8) "my_plan"
["interval"]=>
string(5) "month"
["name"]=>
string(9) "My Plan"
["created"]=>
int(1427441577)
["amount"]=> …Run Code Online (Sandbox Code Playgroud) 我正在编写一个脚本,以便更有效地设置Statamic站点.我遇到的问题是我用来替换文件中的字符串的变量具有未转义的正斜杠并且是用户输入.我怎样才能确保_site_url: http://statamic.com会成为_site_url: http://example.com?
只要没有正斜杠,下面的代码就会起作用.
echo "What's your site URL? Don't forget the protocol (ex. http://)!"
read -e SITE_URL
echo "%s/_site_url: http:\/\/statamic.com/_site_url: $SITE_URL/g
w
q
" | ex _config/settings.yaml
Run Code Online (Sandbox Code Playgroud) 我有一些类似于以下内容的标记:
<h3>A Heading</h3>
<p>Here is a paragraph.</p>
<ul>
<li>First</li>
<li>Second</li>
</ul>
<blockquote>Here's some other block-level element</blockquote>
<h3>The Wrapping Should Stop Before This Heading, but a Second One Should Begin</h3>
<ol>
<li>First</li>
<li>Second</li>
</ol>
<p>Notice the varying block-level elements? It probably doesn't make any difference.</p>Run Code Online (Sandbox Code Playgroud)
我想将所有h3内容(但不包括下一个)包装h3在一个div.
结果应该是:
<div>
<h3>A Heading</h3>
<p>Here is a paragraph.</p>
<ul>
<li>First</li>
<li>Second</li>
</ul>
<blockquote>Here's some other block-level element</blockquote>
</div>
<div>
<h3>The Wrapping Should Stop Before This Heading, but a Second …Run Code Online (Sandbox Code Playgroud)我有一个mixin接受一个我想传递给变量的参数.
@mixin my_mixin($arg) {
background-color: $state-#{$arg}-text;
}
Run Code Online (Sandbox Code Playgroud) 这是我写的 mixin(.scss 格式),但我收到此错误:
"($x) " 之后的 CSS 无效:预期的表达式(例如 1px,粗体),是 "{"
@mixin x_cards_wide($x) {
.card {
&:nth-child(-n + $x) { margin-top: 0; }
&:nth-child($x * n) { margin-right: 0; }
}
}
Run Code Online (Sandbox Code Playgroud)
这是CodePen上的代码.它看起来与我在Chrome中的预期完全一样.Firefox和Safari都看错了.(我是所有3的最新版本.)
我正在研究一种跨多个inline-block元素使用恒定渐变背景的方法.以下是它现在的工作方式:
ol其:before伪元素具有渐变背景(transparent到不透明的颜色)和一个z-index在子元素上方显示它的集合li.li■找的background-color设置为颜色看起来像什么梯度的transparent值设置为.li的color被设置为transparent和具有:before该显示对以前设置为文本伪元素transparent并且它们的z折射率设置为显示上述ol:before(背景梯度).除了Firefox中的相同问题,它还显示两个似乎具有多重混合模式的渐变.一个来自-webkit-linear-gradient一个linear-gradient.但是,解决明显混合模式的问题应该考虑到第三个问题.
我的谷歌搜索让我意识到background-blend-mode,但设置为normal(或任何其他有效值)没有改变任何东西.我认为它只适用于单个元素的多个背景,但我不确定.但是,这可以解释为什么它不能解决我的问题.
我正在尝试将一些目录从一个位置移动到另一个位置,但我需要将其中一个保留在原处(所有文件都将保留在原处)。我尝试了几件事,但似乎没有任何效果。我已经测试了 DIR_COUNT 的值,它按预期工作。但是,当在条件或 case 语句中使用时,它不会按预期工作。
有条件的
#!/bin/bash
DIR_COUNT=$(find path/to/dir/*[^this_dir_stays_put] -type d -maxdepth 0 | wc -l)
echo $DIR_COUNT
if [[ $DIR_COUNT > 0 ]]
then
find path/to/dir/*[^this_dir_stays_put] -type d -maxdepth 0 -exec mv {} new/location \;
echo "Moving dirs."
else
echo "No dirs to move."
fi
Run Code Online (Sandbox Code Playgroud)
案件
#!/bin/bash
DIR_COUNT=$(find path/to/dir/*[^this_dir_stays_put] -type d -maxdepth 0 | wc -l)
echo $DIR_COUNT
case $DIR_COUNT in
0)
echo "No dirs to move."
*)
echo "Moving dirs."
find path/to/dir/*[^this_dir_stays_put] -type d -maxdepth 0 -exec mv …Run Code Online (Sandbox Code Playgroud)