小编Seb*_*ald的帖子

Windows上的Jekyll:Pygments无效

在我总是使用RC之前,我更新到了最新的JekyllBuild(1.0.3).更新代码解析后(使用Pygments)不再起作用.我总是得到以下错误:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:162: warning: cannot close fd before spawn
?[31m  Liquid Exception: No such file or directory - /bin/sh in 2012-01-17-test-post.md?[0m
Run Code Online (Sandbox Code Playgroud)

还有人遇到过这个问题吗?

我不知道红宝石,所以我不能自己调试:(

ruby pygments jekyll

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

检查变量是否存在且=== true

我想检查一下:

  • 数组中的字段isset
  • 该字段=== true

是否可以用一个if陈述来检查这个?

检查是否===会执行该操作但抛出PHP通知.我是否真的必须检查字段是否已设置然后是否为真?

php if-statement notice

14
推荐指数
1
解决办法
6万
查看次数

如何将Git哈希写入(node's)package.json?

有没有办法用git的HEAD哈希自动更新package.json(https://npmjs.org/doc/json.html)的版本号?我想version: 1.0.0+rev82e4b91cfe42cd86e9453b4987b9cc446566de6在项目的package.json文件中有类似的东西.在加号之前的Eveything是手动设置的,每次我提交时都会更新哈希值.

这可能吗?我在这个主题上找不到任何东西: - /

development-environment package node.js gruntjs

9
推荐指数
2
解决办法
4616
查看次数

使用动态/计算键选择<S,K>类型

最新的@types/react(v15.0.6)使用TypeScript 2.1中添加的功能setState,即Pick<S, K>.这是一件好事,因为现在打字是正确的,因为在更新打字之前"不知道" setState正在合并this.state,而不是替换它.

此外,使用Pick使得setState功能在允许输入方面非常严格.不再可以向state组件定义中未定义的属性添加属性(第二个通用属性)React.Component.

但是定义动态更新处理程序也更难.例如:

import * as React from 'react';


interface Person {
  name: string;
  age: number|undefined;
}


export default class PersonComponent extends React.Component<void, Person> {
  constructor(props:any) {
    super(props);

    this.state = { 
      name: '',
      age: undefined
    };
    this.handleUpdate = this.handleUpdate.bind(this);
  }

  handleUpdate (e:React.SyntheticEvent<HTMLInputElement>) {
    const key = e.currentTarget.name as keyof Person;
    const value = e.currentTarget.value;
    this.setState({ [key]: value }); …
Run Code Online (Sandbox Code Playgroud)

generics components typescript reactjs

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

将属性定义为在Typescript中重新生成字符串的字符串或函数

我想创建一个接口,其中属性可以是a stringFunction必须返回a string.我目前有以下内容:

interface IExample {
  prop: string|Function;
}
Run Code Online (Sandbox Code Playgroud)

但这对我来说并不明确,因为Function它可以归还任何东西.我想告诉编译器返回值必须是a string.

这怎么可能在Typescript?或者它可能吗?

declaration typescript tsd

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

根 index.d.ts 内子文件夹的类型

我们创建了类型material-ui@next并希望将它们与库一起发布,我们在上一个测试版中做到了这一点。

这是index.d.ts.

但是这些类型在当前的形式中是不可用的。在开发中,它们在本地使用并且运行良好,但是当使用库 TypeScript 传送文件时,它们似乎使用了不同的发现策略。

declare 'material-ui/Button/Button'不会找到所有引用子文件夹(例如)的类型都是 TypeScript。导入组件时会出现错误:

[ts]
Could not find a declaration file for module 'material-ui/Button/Button'. '<project path>/node_modules/material-ui/Button/Button.js' implicitly has an 'any' type.
  Try `npm install @types/material-ui/Button/Button` if it exists or add a new declaration (.d.ts) file containing `declare module 'material-ui/Button/Button';`
Run Code Online (Sandbox Code Playgroud)

npm_modules文件夹内使用时,TypeScript 是否不接受声明其他导入?因为如上所述,在本地使用它们甚至将它们移动到@types/material-ui将使它们工作。

此外,TypeScript 似乎找到了index.d.ts, 因为从“根”导入有效 ( import { Button} from 'material-ui')。

typescript definitelytyped material-ui

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

在Jekyll插件中调用“ markdownify”

我试图markdownify在Jekyll插件中手动调用过滤器。这是我所拥有的:

module Jekyll

class ColumnBlock < Liquid::Block
    include Jekyll::Filters

    def initialize(tag_name, markup, tokens)
        super
        @col = markup
    end

    def render(context)
        text = super

        '<div class="col-md-' + @col + '">' + markdownify(text) + '</div>'
    end
end

end

Liquid::Template.register_tag('column', Jekyll::ColumnBlock)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误: Liquid Exception: undefined method 'registers' for nil:NilClass

我对Jekyll和Ruby很陌生。我要使用markdownify过滤器时必须包含什么?

plugins liquid jekyll

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