><\/span>Pug rocks!!<\/p<\/span>><\/span>\n<\/span> <\/div<\/span>><\/span>\n<\/span> <\/body<\/span>><\/span>\n<\/span><\/html<\/span>><\/span>\n<\/span><\/pre>\n Now take this code:<\/p>\n This produces the following:<\/p>\n ><\/span>Pug rocks!!<\/p<\/span>><\/span>\n<\/span><\/div<\/span>><\/span>\n<\/span><\/pre>\n It doesn’t really matter what level of indentation you use (you can even use tabs if you have to), but it’s highly recommended that you keep the level of indentation consistent. In this article I’ll be using two spaces.<\/p>\n Secondly, Pug doesn’t have any closing tags. This will obviously save you a fair few keystrokes and affords Pug a clean and easy-to-read syntax.<\/p>\n Now that we’ve got a handle on some basic Pug, let’s quickly go over its syntax. If any of this seems confusing, or you’d like to go more in-depth, be sure to consult the project’s excellent documentation.<\/p>\n You can use Pug to generate a number of document type declarations.<\/p>\n For example doctype html will compile to , the standard HTML5 doctype, whereas doctype strict will give us . Pug will do its best to ensure that its output is valid for the document type.<\/p>\n As mentioned, Pug doesn’t have any closing tags and relies on indentation for nesting. This might take a small amount of getting used to, but once you do, it makes for clean and readable code. By way of an example:<\/p>\n The code above compiles to this:<\/p>\n Notice that Pug is smart enough to close any self-closing tags (such as the element) for us.<\/p>\n Classes and IDs are expressed using a .className and #IDname notation. For example:<\/p>\n Pug also offers us a handy shortcut. If no tag is specified, it will assume a <\/p>\n Both of these compile to:<\/p>\n Attributes are added using brackets:<\/p>\n This results in the following:<\/p>\n\n ><\/span>Pug rocks!!<\/p<\/span>><\/span>\n<\/span> <\/div<\/span>><\/span>\n<\/span> <\/body<\/span>><\/span>\n<\/span><\/html<\/span>><\/span>\n<\/span><\/pre>\n There’s a lot more to say about attributes. For example, you could use JavaScript to include variables in your attributes, or assign an array of values to an attribute. We’ll get on to using JavaScript in Pug in the next section.<\/p>\n Pug provides various methods for adding plain text directly into the rendered HTML.<\/p>\n We’ve already seen how to add plain text inline:<\/p>\n Another way is to prefix a line with a pipe character (|):<\/p>\n ><\/span>Pug rocks!!<\/p<\/span>><\/span>\n<\/span><\/div<\/span>><\/span>\n<\/span><\/pre>\n This gives us the following:<\/p>\n When dealing with large blocks of text, you can just ad a dot . right after the tag name, or after the closing parenthesis, if the tag has attributes:<\/p>\n ><\/span>Pug rocks!!<\/p<\/span>><\/span>\n<\/span><\/pre>\n This results in:<\/p>\n Finally, comments can be added like so:<\/p>\ndiv.remark<\/span>\n<\/span> p Pug rocks!!\n<\/span><\/pre>\n
DOCTYPE<\/h3>\n
Tags<\/h3>\n
npm i -g pug-cli\n<\/span><\/pre>\n
$ pug --version\n<\/span>pug version: 2.0.3\n<\/span>pug-cli version: 1.0.0-alpha6\n<\/span><\/pre>\n
Classes, IDs and Attributes<\/h3>\n
mkdir -p pug-examples\/html\n<\/span>cd pug-examples\n<\/span>touch index.pug\n<\/span><\/pre>\n
pug -w . -o .\/html -P\n<\/span><\/pre>\n
watching index.pug\nrendered \/home\/jim\/Desktop\/pug-examples\/html\/index.html\n<\/pre>\n
doctype html\n<\/span>html(lang='en'<\/span>)<\/span><\/span>\n<\/span> head\n<\/span> title Hello, World!\n<\/span> body\n<\/span> h1 Hello, World!\n<\/span> div.remark<\/span>\n<\/span> p Pug rocks!\n<\/span><\/pre>\n
<\/span>\n<\/span> lang=\"en\"<\/span>><\/span>\n<\/span> ><\/span>\n<\/span>
亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱
><\/span>\n<\/span> ><\/span>Hello, World!<\/h1<\/span>><\/span>\n<\/span>
Plain Text and Text Blocks<\/h3>\n
div.remark<\/span>\n<\/span> p Pug rocks!!\n<\/span><\/pre>\n
div.remark<\/span>\n<\/span>p Pug rocks!!\n<\/span><\/pre>\n
nav\n<\/span> navbar-default div\n<\/span> h1 My Website!\n<\/span> ul\n<\/span> li\n<\/span> a Home\n<\/span> li\n<\/span> a Page 1\n<\/span> li\n<\/span> a Page 2\n<\/span> input\n<\/span><\/pre>\n
Comments<\/h3>\n