在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):cognitom/gulp-slim开源软件地址(OpenSource Url):https://github.com/cognitom/gulp-slim开源编程语言(OpenSource Language):CoffeeScript 75.6%开源软件介绍(OpenSource Introduction):gulp-slimInstallWe need Slim in version 3.0.2 or greater. If you don't have Slim installed, please install Ruby (and RubyGems) first and run gem install slim -v '>= 3.0.2' If you already have Slim installed, make sure you are using the latest version: gem update slim Finally, install npm install gulp-slim --save-dev Usagevar gulp = require("gulp");
var slim = require("gulp-slim");
gulp.task('slim', function(){
gulp.src("./src/slim/*.slim")
.pipe(slim({
pretty: true
}))
.pipe(gulp.dest("./dist/html/"));
}); or write it in CoffeeScript. gulp = require 'gulp'
slim = require 'gulp-slim'
gulp.task 'slim', ->
gulp.src './src/slim/*.slim'
.pipe slim pretty: true
.pipe gulp.dest './dist/html/' OptionsThe options are the same as what's supported by
Set Set You can require one of the plug-ins available with Slim with the slim({
require: 'slim/include'
options: 'include_dirs=[".", "common/includes", "./includes"]'
})
slim({
require: ['slim/include', 'slim/logic_less']
}) Note that when using slim/include you will likely need to use the 'include_dirs' option (as outlined above). See the tests on how to configure include directories with the inclulde partials plugin. You can also add custom options with slim({
pretty: true,
options: 'attr_quote="\'"'
})
slim({
pretty: true,
options: ['attr_quote="\'"', 'js_wrapper=:cdata']
})
slim({
include: true,
options: 'include_dirs="[\'test/fixtures\']"'
}) You can also add any other console options for custom slimrb run options. For example: slim({
prerry: true,
environment: {
cwd: process.cwd(),
env: {
'LC_CTYPE':'ru_RU.UTF-8'
}
}
}) Some ScenariosWith AngularJSIf you want to compile such a source. doctype html
html ng-app="app"
head
body ng-controller="YourController as ctrl"
p {{ desc }}
p
| {{ something }}
a ng-href="https://github.com/{{ user }}"
You need to specify a var gulp = require("gulp");
var slim = require("gulp-slim");
gulp.task('slim', function(){
gulp.src("./src/slim/*.slim")
.pipe(slim({
pretty: true,
options: "attr_list_delims={'(' => ')', '[' => ']'}"
}))
.pipe(gulp.dest("./dist/html/"));
}); With Another EncodingFor example, if var gulp = require("gulp");
var slim = require("gulp-slim");
gulp.task('slim', function(){
gulp.src("./src/slim/*.slim")
.pipe(slim({
pretty: true,
options: "encoding='utf-8'"
}))
.pipe(gulp.dest("./dist/html/"));
}); Passing Data into the TemplateSuppose you have the following template: doctype html
html
head
title = title
body
h1 = title
ul
- for u in users
li = u.name You can fill in the variables by passing a plain old JavaScript object
as slim({
data: {
title: "Just a list of usernames",
users: [
{ name: "Fred" },
{ name: "Bill" },
{ name: "Harry" }
]
}
}) Changelog0.3.0
0.2.0
0.1.0Special thanks to @dmke !! See here.
0.0.11
0.0.8
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论