玉缩进错误 [英] Jade indentation errors

查看:116
本文介绍了玉缩进错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的快递网站,我正在使用玉石。所以我决定尝试修改我的布局文件,以便我可以开始设计我的网站。我修改了原始的布局代码(它的工作),但是我开始在任何扩展布局的文件中获得缩进错误:

  500错误:/home/kevin/Blue/views/layout.jade:6 4 | p Hello World无效的缩进,您可以使用选项卡或空格,但不能同时使用
4 | p Hello World
无效的缩进,您可以使用选项卡或空格,但不能同时使用
在Object.Lexer.indent(/home/kevin/Blue/node_modules/jade/lib/lexer.js:679:15) )
在Object.Lexer.next(/home/kevin/Blue/node_modules/jade/lib/lexer.js:777:15)
在Object.Lexer.lookahead(/ home / kevin / Blue /node_modules/jade/lib/lexer.js:107:46)
在Object.Parser.lookahead(/home/kevin/Blue/node_modules/jade/lib/parser.js:115:23)$ b $在Object.Parser.peek的(b)/ /lib/parser.js:640:22)
在Object.Parser.parseTag(/home/kevin/Blue/node_modules/jade/lib/parser.js:624:17)
在Object。 Parser.parseExpr(/home/kevin/Blue/node_modules/jade/lib/parser.js:198:21)
在Object.Parser.block(/ home / kevin / Blue / node_modules / jade / lib / parser .js:592:25)
在Object.Parser.tag(/home/kevin/Blue/node_modules/jade/lib/parser.js:721:26)

所以我有的代码是这样的:



index.jade

 扩展布局

块内容
p Hello World

  doctype 5 
html
head
title = title
link(rel ='stylesheet',href = '/stylesheets/style.css')

body
div#header
p这是头
块内容
请记住,我没有错误地拼写任何错误,而且我知道如何使用extends选项将文件链接在一起。其实这个代码工作得很好,直到我开始搞乱布局文件。所有这些都是一个缩写问题。我试着弄清楚是否是我的文本编辑器导致问题,并且我一直没有成功地确定是否是,因为我无法再次获得代码。



我正在使用崇高的文字2编辑器来编写这个玉石代码。如果文本编辑器没有正确缩进,有人可以帮助我学习如何解决它吗?

解决方案

Sublime Text的手角,应该有一个标签,说空格:N 标签大小:N 其中 N 是一个数字。选择此选项,您将看到将整个文档的缩进转换为使用选项卡或空格的选项:




  • 转换

  • 将缩进转换为标签


So for my Express site, I'm using jade. So I decided to try modifying my layout file so I can start designing my site. I modified the original layout code (which worked), but I started getting indentation errors in any file that extends layout like this:

500 Error: /home/kevin/Blue/views/layout.jade:6 4| p Hello World Invalid indentation, you can use tabs or spaces but not both
4| p Hello World
Invalid indentation, you can use tabs or spaces but not both
at Object.Lexer.indent (/home/kevin/Blue/node_modules/jade/lib/lexer.js:679:15)
at Object.Lexer.next (/home/kevin/Blue/node_modules/jade/lib/lexer.js:777:15)
at Object.Lexer.lookahead (/home/kevin/Blue/node_modules/jade/lib/lexer.js:107:46)
at Object.Parser.lookahead (/home/kevin/Blue/node_modules/jade/lib/parser.js:115:23)
at Object.Parser.peek (/home/kevin/Blue/node_modules/jade/lib/parser.js:92:17)
at Object.Parser.tag (/home/kevin/Blue/node_modules/jade/lib/parser.js:640:22)
at Object.Parser.parseTag (/home/kevin/Blue/node_modules/jade/lib/parser.js:624:17)
at Object.Parser.parseExpr (/home/kevin/Blue/node_modules/jade/lib/parser.js:198:21)
at Object.Parser.block (/home/kevin/Blue/node_modules/jade/lib/parser.js:592:25)
at Object.Parser.tag (/home/kevin/Blue/node_modules/jade/lib/parser.js:721:26)

So the code that I have is this:

index.jade

extends layout

block content
    p Hello World

and

doctype 5
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')

    body
        div#header
            p This is the header
        block content

Keep in mind that I didn't spell anything incorrectly, and I do know how to link together files using the extends option just fine. In fact, the code worked perfectly fine until I started messing with the layout file. All of this is mostly an indention issue. I tried figuring out if it is my text editor causing the problem, and I have been unsuccessful figuring out if it is, as I can't get the code working again.

I am using the sublime text 2 editor to write this jade code. If it is the text editor not indenting correctly, could somebody help me learn how to fix it?

解决方案

In the lower right-hand corner of Sublime Text, there should be a label that says Spaces: N or Tab Size: N where N is a number. Select this and you'll see options to convert the entire document's indentation to use either tabs or spaces:

  • Convert Indentation to Spaces
  • Convert Indentation to Tabs

这篇关于玉缩进错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆