小编Jus*_*tin的帖子

用于Gulp的PHP Linter with Rules文件?

是否有一个NPM Gulp模块,它不仅可以使用lint我的PHP代码,而且还有一个配置/规则文件,允许我指定某些内容,例如:

  • {在下一行打开课程
  • 所有方法都必须具有正确的DocType
  • 等等

我使用ESLinter作为我的JS代码非常好用.它有一个.eslintrc文件,我指定我的所有规则.有点像:

{
  "rules": {
    "indent": [ 2, 2, {"SwitchCase": 1} ],
    "linebreak-style": [ 2, "unix" ],
    "eol-last": 1,
    "no-multi-spaces": 1,
    "quotes": [ 1, "single", "avoid-escape" ],
    "semi": [ 2, "always" ],
    "array-bracket-spacing": [ 1, "always", { "objectsInArrays": false } ]
  }
}
Run Code Online (Sandbox Code Playgroud)

php lint software-quality rules eslint

5
推荐指数
1
解决办法
437
查看次数

我有一些关于 Sapper/Svelte 的问题

我第一次开始使用 Sapper ( https://sapper.svelte.technology )。到目前为止我真的很喜欢它。我需要它做的一件事是显示我的应用程序中可用组件的列表并显示有关它们的信息。理想情况下,有一种方法可以根据页面上的动态绑定来更改组件的外观。

我有一些关于使用该框架的问题。

首先,我将提供我的代码片段,然后是屏幕截图:

[slug].html
-----------

<:Head>
<title>{{info.title}}</title>
</:Head>

<Layout page="{{slug}}">
    <h1>{{info.title}}</h1>

    <div class="content">
         <TopBar :organization_name />
    <br>
    <h3>Attributes</h3>
    {{#each Object.keys(info.attributes) as attribute}}
    <p>{{info.attributes[attribute].description}} <input type="text" on:keyup="updateComponent(this.value)" value="Org Name" /></p>
    {{/each}}
    </div>
</Layout>

<script>
import Layout from '../_components/components/Layout.html';
import TopBar from '../../_components/header/TopBar.html';

let COMPONENTS = require('../_config/components.json');

export default {
    components: {
        Layout, TopBar
    },

      methods: {
          updateComponent(value) {
            this.set({organization_name: value});
          }
      },

  data() {
      return {
        organization_name: 'Org Name'
      }
  },

  preload({ params, query }) {

    params['info'] …
Run Code Online (Sandbox Code Playgroud)

javascript frameworks node.js svelte angular

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

Sapper / Svelte SASS预处理?

所以我正在检查Sapper / Svelte的真实世界实现:https : //github.com/sveltejs/realworld

我已经阅读了很多有关SASS预处理的内容,似乎还没有完全支持SASS预处理,但是上面有一些文档。综上所述,在对webpack.client.config.js文件进行以下修改之后,我应该能够对标签进行预处理:

const svelte = require('rollup-plugin-svelte');
const sass = require('svelte-preprocess-sass').sass;

const config = require('sapper/webpack/config.js');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
    entry: config.client.entry(),
    output: config.client.output(),
    resolve: {
        extensions: ['.js', '.html']
    },
    module: {
        rules: [
            {
                test: /\.html$/,
                exclude: /node_modules/,
                use: {
                    loader: 'svelte-loader',
                    options: {
                        hydratable: true,
                        emitCss: !config.dev,
                        cascade: false,
                        store: true
                    }
                }
            },
            config.dev && {
                test: /\.css$/,
                use: [
                    { …
Run Code Online (Sandbox Code Playgroud)

npm svelte

2
推荐指数
1
解决办法
2228
查看次数

在PHP中使用其他文本包围字符串的一些方法?

我有以下PHP函数:

    public function createOptions($options, $cfg=array()) {
        $cfg['methodKey'] = isset($cfg['methodKey']) ? $cfg['methodKey'] : 'getId';
        $cfg['methodValue'] = isset($cfg['methodValue']) ? $cfg['methodValue'] : 'getName';
        $cfg['beforeKey'] = isset($cfg['beforeKey']) ? $cfg['beforeKey'] : '';
        $cfg['beforeValue'] = isset($cfg['beforeValue']) ? $cfg['beforeValue'] : '';
        $cfg['afterKey'] = isset($cfg['afterKey']) ? $cfg['afterKey'] : '';
        $cfg['afterValue'] = isset($cfg['afterValue']) ? $cfg['afterValue'] : '';
        $array = array();
        foreach ($options as $obj) {
            $array[$cfg['beforeKey'] . $obj->$cfg['methodKey']() . $cfg['afterKey']] = $cfg['beforeValue'] . $obj->$cfg['methodValue']() . $cfg['afterValue'];
        }
        return $array;
}
Run Code Online (Sandbox Code Playgroud)

这是我在我的应用程序中使用来从数组数据创建选择框的东西.我刚刚添加了4个新的$ cfg变量,用于在选择框的键和值之前或之后添加字符串.因此,例如,如果我的下拉列表默认情况下看起来像"A,B,C",我可以通过:

$cfg['beforeValue'] = 'Select ';
$cfg['afterValue'] = ' …
Run Code Online (Sandbox Code Playgroud)

javascript php arrays string text

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

使用类定义信息数组的最佳方法

我有一个数据库表,存储项目的"类型",存储1,2或3,其中:

1 ="有效"2 ="无效"3 ="已取消"

目前,我将此映射存储在config.php中的数组中,使其成为可从我的整个应用程序访问的全局变量.它看起来像:

$project_types = array(1 => "Active", 2 => "Inactive", 3 => "Cancelled");
Run Code Online (Sandbox Code Playgroud)

现在,我有一个Project类,它有get_type()和set_type()方法来按预期更改整数值.我想要一个get_type_name()方法.这里的任何人都可以解释这个方法应该是什么样子 目前,我有一些看起来像这样的东西:

public function get_type_name() {
    global $project_types;
    return $project_types[$this->get_type()];
}
Run Code Online (Sandbox Code Playgroud)

我上面的数组应该以某种方式存在于我的Project类中,但我只是不确定要采取什么路由.

谢谢.

php arrays mapping types project

0
推荐指数
1
解决办法
43
查看次数

如何将变量传递到 modx 中的子块

我在 ModX 中有一个片段,看起来像这样:

$array = array(
    'id' => 1,
    'title' => 'Title of Story',
    'content' => 'Content of story...'
);

echo $modx->getChunk('chunk_story_page', $array);
Run Code Online (Sandbox Code Playgroud)

我的故事页面 HTML 看起来像这样:

<div class="story">
    <h1>[[+title]]</h1>
    <div class="content">
        [[+content]]
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

现在我希望能够从该块中调用另一个块并通过它传递我的数据。我将以下内容放置在上述 HTML 的下方。

[[$chunk_story_page_extra &title=`[[+title]]`&content=`[[+content]]`]]
Run Code Online (Sandbox Code Playgroud)

不言而喻,但是上面的行没有产生任何输出。

关于我在那条线上可能做错了什么的任何线索吗?我确信这与语法有关。

php parameter-passing modx chunks modx-revolution

0
推荐指数
1
解决办法
3793
查看次数