• Y0_642942
  • 48.5KB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-05-27 04:16
html-brunch-static 在早午餐中转换静态html文件。 HTML的早午餐静电是处理器,一个插件设计用来处理静态文件。 html-brunch-static可以将多种模板语言转换为静态html文件,并支持布局和局部视图。 如果您想着手编写自己的处理器,请。 否则,请继续阅读。 安装 html-brunch-static取决于 ,因此,您将需要安装两个插件。 推荐的方法是通过npm: npm install --save-dev brunch-static html-brunch-static 或手动: 在package.json中添加"brunch-static": "xyz" 在package.json中添加"html-brunch-static": "xyz" 运行npm install 或者,您可以将最新的git版本用于: "brunch-stati
  • html-brunch-static-master
  • src
  • .gitignore
  • index.js
  • package-lock.json
  • package.json
![Release]( # html-brunch-static Transform static html files in brunch. html-brunch-static is a processor for [brunch-static](, a [brunch]( plugin designed to handle static files. html-brunch-static can convert a variety of template languages into static html files with support for layouts and partial views. If you want to dive into writing your own processor, [jump down](#writing-html-brunch-static-processors). Otherwise, keep reading. ## Installation html-brunch-static depends on [brunch-static](, so, you will need to install both plugins. The recommended method is via npm: ```bash npm install --save-dev brunch-static html-brunch-static ``` Or manually: * Add `"brunch-static": "x.y.z"` to package.json * Add `"html-brunch-static": "x.y.z"` to package.json * Run `npm install` * Alternatively, you may use the latest git version with: * `"brunch-static": "git+ssh://"` * `"html-brunch-static": "git+ssh://"` ## Configuration Add html-brunch-static to your list of brunch-static processors: ```coffee exports.config = ... plugins: static: processors: [ require('html-brunch-static') { processors: [ ... ] defaultContext: { ... } partials: ... layouts: ... handlebars: { enableProcessor: ... helpers: { ... } ... } minify: ... } ] ``` * **processors** _(default: `[]`)_ > _processors_ is an array of html processors. See [available processors](#available-processors) below for a list. * **defaultContext** _(default: `{}`)_ > To set default values for the _context_ of your files, use _defaultContext_. See "[Context, Layouts, and Partials](#context-layouts-and-partials)" below for more details on the context. * **partials** _(default: `/partials?/`)_ > _partials_ is an [anymatch]( that will be used to determine what files are [partials](#partials). This means it can be either a string with globs, a regex, or a function that takes a single parameter (a filename) and returns true if it is a partial view and false otherwise. The default setting will match any filename that includes the word "partial" (or "partials") anywhere in the path, for example: `app/partials/whatever.ext`. * **layouts** _(default: `/layouts?/`)_ > Like _partials_ above, _layouts_ is an [anymatch]( that will be used to determine what files are [layouts](#layouts). It may also be a string with globs, a regex, or a function that takes a filename and returns true/false. The default setting will match any filename that includes the word "layout" (or "layouts") anywhere in the path, for example: `app/layouts/whatever.ext`. * **handlebars** _(default: `null`)_ > Default options for handlebars (see [handlebars.js documentation]( These options, with the exception of _enableProcessor_ and _helpers_ (see below), are passed verbatim to handlebars and can be overridden in the front matter ([see below](#context-layouts-and-partials)). > > * **enableProcessor** _(default: `false`)_ > > > _enableProcessor_ may either be true or an object containing objects to pass to the handlebars processor. Either way will enable the built-in support for handlebar files. See below for the options available. > > * **helpers** _(default: `null`)_ > > _helpers_ can be used to specify custom handlebars helpers. This option should be a hash where the keys are the names of the helpers and the values are functions. This hash is passed, verbatim, to `Handlebars.registerHelper()` (see [handlebars.js documentation]( * **minify** _(default: `false`)_ > Minify the resulting html using [html-minifier]( To enable, set this value to `true` to use the default options, or set to a hash of options that will be passed directly to html-minifier. See html-minifier's documentation for a list of valid options and their defaults. The following options are available if you enable the built-in handlebars processor: ```coffee enableProcessor: fileMatch: ... fileTransform: ((filename) -> ...) ``` * **fileMatch** _(default: `/\.static\.(hbs|handlebars)$/`)_ > _fileMatch_ is an [anymatch]( that is used to determine which files will be handled by the handlebars processor. As an anymatch, it may be a string with globs, a regex, or a function that takes a filename and returns true or false. The default will match files that end with `.static.hbs` or `.static.handlebars`. * **fileTransform** _(default: `(f) -> f.replace(/\.static\.\w+$/, '.html')`)_ > _fileTransform_ converts the input filename into an html filename. It takes a filename as input and returns the new filename with the html extension. If you set the _fileMatch_ property above, you'll probably need to set this option as well to ensure that your output files end with the html extension. ### Note The value of _partials_ and _layouts_ may be the same if you want to put them all together. In a lot of similar static site generators, partials and layouts might start with an underscore, such as `_layout.html`. You can do this (and set _partials_ and _layouts_ to something like `"**/_*"`), but be aware that, by default, brunch will ignore any files that start with an underscore. What this means is that any changes to these files will not trigger brunch to recompile any files that are dependent on those partials and layouts. This problem can be fixed if you change brunch's `conventions.ignored` setting to not ignore files that begin with an underscore. ## Available Processors Below are the currently available processors for html-brunch-static. If you'd like for your processor to be included in this list, [create an issue]( with your project's URL and a description. * Markdown: [marked-brunch-static]( * Nunjucks: [njk-brunch-static]( * Pug: [pug-brunch-static]( * Jade: [jade-brunch-static]( * Handlebars: built-in (see the [handlebars.enableProcessor option](#configuration) above) ## Context, Layouts, and Partials html-brunch-static has full support for using layouts and partials in your templates. In fact, you can have multiple levels of layouts if you'd like. These features are orchestrated by including [YAML]( or JSON _front matter_ at the top of your template files. Front matter sets the _context_ of the file, which is bubbled up (and possibily overridden) by the layout, and the layout's layout, etc. ### Example By default, processors will look for files ending in the extension `.static.ext` (ex: `.static.jade`). This way, html-brunch-static does not interfere with other brunch plugins which are meant to handle dynamic files. This behavior can be changed using the `fileMatch` and `fileTransform` options for the respective processor (see documentation for [marked-brunch-static](, [jade-brunch-static](, etc). Armed with that knowledge, let's say I have the following file `app/`: ```markdown --- title: html-brunch-static's awesome test page _options: layout: app/layouts/main.static.jade partials: - app/partials/greetings.static.hbs --- {{>greetings}} This is **html-brunch-static's** super awesome test page. ``` Everything between the `---`'s is the front matter. Here, I've chosen to write my
    • extend-json:一个npm模块,用于填充JSON文件
      extend-json是一个npm模块,用于填充JSON文件,其他JSON文件或指定的函数。 扩展对象 ">>fileB": {"file" : "./fileB.json"} 扩展数组 [{">>fileB": {"file" : "./fileB.json", "replace":true}}] var extend...
    • npm-autoinit:对npm发出“ ENOENT package.json”警告警告
      如果您错过了npm正在使用的目录中的package.json ,它将抱怨。 $ npm install thingy … npm WARN ENOENT ENOENT: no such file or directory, open '/tmp/tmpdir/R3semq/package.json' npm WARN EPACKAGEJSON /...
    • edit-package-json:“ edit-package-json”是一个NPM软件包,它对“ package.json
      NPM 包:edit-package-json edit-package-json是一个NPM软件包, package.json文件进行更改。 它可以在命令行上使用(作为editPackageJson )或在 Node 应用程序中使用。 edit-package-json's主要目的是添加...
    • package-json-cli:从npm注册表中获取软件包的package.json
      npm注册表中获取软件包的package.json 安装 $ npm install --global package-json-cli 用法 $ package-json --help Usage $ package-json <name> [version] Example $ package-json ava { "name": "ava",...
    • manage-npm-scripts:管理 package.json `npm run` 脚本
      无需编辑 package.json 即可管理 package.json npm run scripts $ npm install -g manage-npm-scripts $ npm-script set example "echo This is an example" set: example $ npm-script ls example: echo This is ...
    • json-forms
      JSON Forms React种子应用程序 该种子演示了如何将与React结合使用,以呈现用于显示任务实体的简单表单。 它基于create-react-app ,仅包含较小的修改。 执行npm ci以安装必备组件。 如果要获得最新的发行版本,请...
    • json2ify:用于浏览器的 JSON2 npm 模块
      json2ify 用于 commonsJS 友好包含的浏览器的 JSON2 npm 模块 来源: :
    • package-json:从npm注册表中获取软件包的元数据
      $ npm install package-json 用法 const packageJson = require ( 'package-json' ) ; ( async ( ) => { console . log ( await packageJson ( 'ava' ) ) ; //=> {name: 'ava', ...} // Also works with scoped...
    • rewrite-shrinkwrap-urls:重写npm-shrinkwrap.json中的URL
      有时有必要更新npm-shrinkwrap.json package-lock.json文件或package-lock.json文件中的“已解析” URL,例如,当您要将所有软件包指向私有npm注册表(例如。 该软件包提供了一个可以做到这一点的工具。 它带有一...
    • npm-start
      Paketo NPM启动Cloud Native Buildpack NPM启动CNB设置给定应用程序的启动命令。 start命令是从package.json的内容生成的。例如,给出一个具有以下内容的package.json : { ...