原作者:Ryan Welcher,WordPress Developer Blog,2024-04-16。来源:Creating an external project template for create-block。中文翻译与静态技术注释:未完纪,2026-10-05。原文感谢@greenshady、@bph和@dansoschin反馈与审阅。以下模板、npm命令和输出只作静态对照,没有安装、生成或构建插件。
@wordpress/create-block可以用一条命令一致地生成自定义区块。它接收值、处理值,再把结果插进模板文件;模板决定文件位置、插入位置和默认值。内置模板适合简单区块,外部项目模板则能控制交互模式或现有CLI选项无法细调的生成内容。
通过--template可以传入发布在npm上的模板,例如Interactivity API入门模板,也可以传本地目录。这既适合制作测试模板,也适合代码不能公开共享的内部项目。原文使用@latest作为演示;团队复现应锁定审查过的版本,因为模板包和安装脚本会执行代码。
npm托管模板的原命令
npx @wordpress/create-block@latest my-first-interactive-block --template @wordpress/create-block-interactive-template
本地模板的规范写法如下。原页一处把--template排版成混合长短横线,下面只修正为两个ASCII连字符;完整原代码在文末对照。
本地模板命令:连字符排版修订
npx @wordpress/create-block@latest custom-template-block --template ./path/to/files
一、准备配套仓库和目录
首先安装Node.js,可参考WordPress官方Node开发工具准备说明。原文随后克隆配套仓库并进入目录:
取得教程模板
git clone https://github.com/wptrainingteam/external-project-template.git
cd external-project-template

全部模板与配置放在my-template,位于项目根下便于本地测试。index.js保存配置,files及其子目录保存模板文件。目录名本身不限,但配置路径必须对应;关键是把生成插件根目录的文件与生成区块src目录的文件分开。
二、配置入口与默认值
外部模板由配置入口index.js和Mustache模板两部分组成。Mustache是无逻辑模板语法,可以用于HTML、配置和源码,通过给定对象或映射展开标签。index.js导出一个配置对象;源文提到有六个可用配置属性,细节链接到对应create-block文档。这里运行在Node.js中,使用CommonJS的require和module.exports,不是前端项目常用的ES Modules。
先从path导入join并导出空对象,再用pluginTemplatesPath与blockTemplatesPath指向files/plugin和files/block。即使目录暂时为空也可以先搭出配置。assetsPath用于不需要变量处理的图片、字体等静态资产,本文示例不使用它。
起始index.js
/**
* Dependencies
*/
const { join } = require("path");
module.exports = {};
指定两类模板目录
/**
* Dependencies
*/
const { join } = require("path");
module.exports = {
pluginTemplatesPath: join(__dirname, "files/plugin"),
blockTemplatesPath: join(__dirname, "files/block"),
};
大部分设置放在defaultValues,它们概念上分为项目设置、插件头与区块元数据。作者习惯使用Prettier,并在编辑器保存时格式化JavaScript。create-block生成package.json时,对依赖、脚本、wp-env/wp-scripts有专门配置项;customPackageJSON是用来补充其他package.json字段的通用入口。
添加Prettier配置
/**
* Dependencies
*/
const { join } = require("path");
module.exports = {
defaultValues: {
customPackageJSON: {
prettier: "@wordpress/prettier-config",
},
},
pluginTemplatesPath: join(__dirname, "files/plugin"),
blockTemplatesPath: join(__dirname, "files/block"),
};
运行后生成的package.json会加入prettier: "@wordpress/prettier-config"。接着设置version、namespace和description;它们是默认值,仍可被相应CLI参数覆盖。
插件默认元数据
/**
* Dependencies
*/
const { join } = require("path");
module.exports = {
defaultValues: {
version: "1.0.0",
namespace: "developer-blog",
description:
"A plugin created by the create-block tool using a custom external project template.",
customPackageJSON: {
prettier: "@wordpress/prettier-config",
},
},
pluginTemplatesPath: join(__dirname, "files/plugin"),
blockTemplatesPath: join(__dirname, "files/block"),
};
三、动态与交互式变体
变体属于具体模板,通过--variant选择。create-block内置模板有static和dynamic变体;本教程自行定义dynamic与interactive两个变体。dynamic生成普通动态区块,interactive则使用WordPress 6.5引入的Interactivity API。
variants中的每个对象含有会与全局defaultValues合并、并覆盖同名值的配置。先把render设为file:./render.php并建立两个空变体。通常第一个变体(此处dynamic)作为不传--variant时的默认;主要默认值应足以生成普通插件。
建立变体骨架
/**
* Dependencies
*/
const { join } = require("path");
module.exports = {
defaultValues: {
version: "1.0.0",
namespace: "developer-blog",
description:
"A plugin created by the create-block tool using a custom external project template.",
render: "file:./render.php",
customPackageJSON: {
prettier: "@wordpress/prettier-config",
},
},
variants: {
dynamic: {},
interactive: {},
},
pluginTemplatesPath: join(__dirname, "files/plugin"),
blockTemplatesPath: join(__dirname, "files/block"),
};
interactive再设置viewScriptModule、覆盖build/start脚本并启用supports.interactive。这处supports.interactive是原教程写法,原样保留供对照,不应直接当成当前block.json的正确开关。当前官方Block Supports文档使用supports.interactivity,并把interactive列为该对象的子属性;两者的层级不同。迁移时请按目标版本校正该字段,不要仅因生成配置含interactive就断言交互指令已经启用。三个调整都来自此版本教程;Interactivity API实现细节不在本篇范围。注意--experimental-modules是原版本脚本参数,使用其他版本前需查对应文档。
完整交互式变体配置
/**
* Dependencies
*/
const { join } = require("path");
module.exports = {
defaultValues: {
version: "1.0.0",
namespace: "developer-blog",
description:
"A plugin created by the create-block tool using a custom external project template.",
render: "file:./render.php",
customPackageJSON: {
prettier: "@wordpress/prettier-config",
},
},
variants: {
dynamic: {},
interactive: {
viewScriptModule: "file:./view.js",
customScripts: {
build: "wp-scripts build --experimental-modules",
start: "wp-scripts start --experimental-modules",
},
supports: {
interactive: true,
},
},
},
pluginTemplatesPath: join(__dirname, "files/plugin"),
blockTemplatesPath: join(__dirname, "files/block"),
};
四、Mustache文件与16个通用变量
插件模板输出到生成插件根目录,如主PHP、readme.txt和composer.json;区块模板输出到src目录,如block.json、index.js、edit.js和render.php。不论哪类模板,都必须以.mustache结尾,否则create-block忽略该文件。
files/plugin示例含.editorconfig.mustache、.eslintrc.mustache、.gitignore.mustache、readme.txt.mustache及$slug.php.mustache。生成时去掉.mustache后缀;文件名中的$slug也会被替换。文件内的{{title}}等Mustache值由模板、用户参数或create-block根据其他值派生。
插件头的模板标签
<?php
/**
* Plugin Name: {{title}}
*/
生成默认变体
npx @wordpress/create-block my-example-template-block --template ./my-template
上面的slug为my-example-template-block,因此$slug.php.mustache生成my-example-template-block.php,标题派生为My Example Template Block。原文列出的16项通用模板变量如下:
{{namespace}}{{namespaceSnakeCase}}{{namespacePascalCase}}{{slug}}{{slugPascalCase}}{{slugSnakeCase}}{{title}}{{description}}{{author}}{{pluginURI}}{{license}}{{licenseURI}}{{domainPath}}{{updateURI}}{{version}}{{textdomain}}
变体还会产生布尔变量:选择interactive时isInteractiveVariant为true、isDynamicVariant为false;不传变体或选择dynamic时相反。它们可以决定文件是否生成,或同一文件内输出哪一段内容。
Mustache条件语法
{{#VariableVar}}
If VariableVar is true, then this content is output
{{/VariableVar}}
五、只有交互变体才输出view.js
最初的view.js.mustache未加条件,因此即使生成dynamic,它仍会输出一个view.js,这不是预期。原文件如下:
原来的无条件view.js模板:问题示例
/**
* WordPress dependencies
*/
import { store } from '@wordpress/interactivity';
store( '{{slug}}', {
state: {},
actions: {},
callbacks: {},
} );
修复是在整个模板外包裹isInteractiveVariant条件。下面才是应采用的条件模板:
完整条件view.js.mustache
{{#isInteractiveVariant}}
/**
* WordPress dependencies
*/
import { store } from '@wordpress/interactivity';
store( '{{slug}}', {
state: {},
actions: {},
callbacks: {},
} );
{{/isInteractiveVariant}}
再次运行默认dynamic生成命令时,条件为false,模板得到空内容;create-block会检查生成文件有无内容,空文件不会写入磁盘。因此不是“出现view.js但内容为空”,而是不会生成该文件。
六、一个render.php保留共享内容与不同变体分支
另一种情况是文件总要存在,但不同变体需要不同内容。render.php.mustache顶部的PHP说明始终输出;其后分别按isInteractiveVariant和isDynamicVariant选择渲染部分。交互版初始化全局state和context,输出data-wp-interactive及上下文属性;动态版只输出普通段落。原代码保留wp_kses_data、get_block_wrapper_attributes及esc_html_e等输出处理:
完整render.php.mustache
<?php
/**
* PHP file to use when rendering the block type on the server to show on the front end.
*
* The following variables are exposed to the file:
* $attributes (array): The block attributes.
* $content (string): The block default content.
* $block (WP_Block): The block instance.
*
* @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render
*/
{{#isInteractiveVariant}}
// Define some global state
wp_interactivity_state(
'{{slug}}',
array()
);
// Define some context.
$context = array();
?>
<p <?php echo wp_kses_data( get_block_wrapper_attributes() ); ?>
data-wp-interactive="{{slug}}"
<?php echo wp_interactivity_data_wp_context( $context ); ?>
>
<?php esc_html_e( '{{title}} – hello from an interactive block!', '{{textdomain}}' ); ?>
</p>
{{/isInteractiveVariant}}
{{#isDynamicVariant}}
?>
<p <?php echo wp_kses_data( get_block_wrapper_attributes() ); ?>>
<?php esc_html_e( '{{title}} – hello from a dynamic block!', '{{textdomain}}' ); ?>
</p>
{{/isDynamicVariant}}
七、Transformer:查看全部生成值并加入自定义变量
transformer是defaultValues中的特殊函数。它接收create-block构造的view,返回修改后的值;不能把它放成与defaultValues无关的随意顶层属性。先用console.log(view)查看所有变量并原样返回:
包含transformer的完整index.js
/**
* Dependencies
*/
const { join } = require("path");
module.exports = {
defaultValues: {
transformer: (view) => {
console.log(view);
return view;
},
version: "1.0.0",
namespace: "developer-blog",
description:
"A plugin created by the create-block tool using a custom external project template.",
render: "file:./render.php",
customPackageJSON: {
prettier: "@wordpress/prettier-config",
},
},
variants: {
dynamic: {},
interactive: {
viewScriptModule: "file:./view.js",
customScripts: {
build: "wp-scripts build --experimental-modules",
start: "wp-scripts start --experimental-modules",
},
supports: {
interactive: true,
},
},
},
pluginTemplatesPath: join(__dirname, "files/plugin"),
blockTemplatesPath: join(__dirname, "files/block"),
};
再次生成用于查看变量
npx @wordpress/create-block my-example-template-block --template ./my-template
源教程终端会打印如下对象。它包含常用元数据、npm配置、脚本路径、variantVars以及textdomain等;这是原文观测对象,不是本文执行结果。输出中的GPL-2.0-or-later是生成插件的license字段,不能据此推定博客正文使用同一许可证。
原终端view对象完整输出
{
'$schema': 'https://schemas.wp.org/trunk/block.json',
apiVersion: 3,
plugin: true,
namespace: 'developer-blog',
slug: 'my-example-template-block',
title: 'My Example Template Block',
description: 'A plugin created by the create-block tool using a custom external project template.',
dashicon: undefined,
category: 'widgets',
attributes: undefined,
supports: undefined,
author: 'The WordPress Contributors',
pluginURI: undefined,
license: 'GPL-2.0-or-later',
licenseURI: 'https://www.gnu.org/licenses/gpl-2.0.html',
domainPath: undefined,
updateURI: undefined,
version: '1.0.0',
wpScripts: true,
wpEnv: false,
npmDependencies: [],
npmDevDependencies: undefined,
customScripts: {},
folderName: './src',
editorScript: 'file:./index.js',
editorStyle: 'file:./index.css',
style: 'file:./style-index.css',
viewStyle: undefined,
render: 'file:./render.php',
viewScriptModule: undefined,
viewScript: undefined,
variantVars: { isDynamicVariant: true, isInteractiveVariant: false },
customPackageJSON: { prettier: '@wordpress/prettier-config' },
customBlockJSON: undefined,
example: undefined,
textdomain: 'my-example-template-block'
}
可以用transformer修改多个派生值。原文举Block Development Examples仓库为例,它会在slug、title等中加入生成值。本教程则新增工具没有直接提供的requiresAtLeast变量,以适应两个变体不同的最低WordPress要求。
先把$slug.php.mustache中Requires at least插件头改成变量,再让transformer读取view.variantVars.isInteractiveVariant:交互版返回6.5,动态版返回6.1,同时以展开语法保留view的其他值。
插件头使用新变量
* Requires at least: {{requiresAtLeast}}
最低版本transformer
transformer: (view) => {
const {
variantVars: { isInteractiveVariant },
} = view;
return {
...view,
requiresAtLeast: isInteractiveVariant ? "6.5" : "6.1",
};
},
选择交互变体
npx @wordpress/create-block my-example-template-block --template ./my-template --variant interactive
原预期插件头输出
* Requires at least: 6.5
这样得到可复用的外部模板;还可以尝试新增其他变体。6.1/6.5只是原教程示例,不是对任意API和依赖的兼容承诺。生成后应实际核对插件头、package.json、block.json、view.js、render.php及构建结果,不能只看配置对象就认定生效。
八、原评论中的勘误与维护提醒
2024-05-02,Mark Salvatore按配套仓库final分支试验,发现namespace未按模板进入生成结果,仍显示create-block前缀。2024-05-03,Ryan Welcher确认早期命令有误并更新文章,强调模板路径相对于执行命令的当前目录。网页正文和评论仍可能有长横线、包名前缀等排版差异,执行前应检查准确ASCII命令、已固定版本及CLI帮助。
2024-05-04的后续评论报告:assetsPath、updateURI、licenseURI、slug与script没有按预期输出,其中script进入package.json的scripts而非成为src/script.js;textdomain似乎不随设置变化;带命名空间/slug的namespace出现额外路径拼接。这些是原评论者报告,不是本文实测或适用于当前所有版本的断言。它们提醒我们给模板做生成回归,检查每项值实际落到哪个文件。
模板和npm依赖属于会执行的供应链输入。只使用可信来源,固定版本,审阅安装脚本、包清单与生成差异;npm pack检查也应在隔离环境进行,防止把私有配置和密钥发布出去。没有执行任何教程命令,静态审查不证明不存在漏洞。
原始命令排版与来源许可说明
为保留原文差异,下面记录原页混合连字符的本地命令,仅供诊断排版,不应照抄:
原页排版形式
npx @wordpress/create-block@latest custom-template-block -–template ./path/to/files
原作者Ryan Welcher与感谢名单保留。原博客未声明可确认的独立文章许可证;本文不把WordPress程序许可当作文章许可。配套仓库公开元数据也未提供独立LICENSE标识。原代码、模板变量和生成物输出中的许可证信息已保留;其中生成插件示例声明GPL-2.0-or-later,下面附其引用的GPLv2完整文本,不改变文章及配图原权利。中文翻译、条件块说明、CLI连字符修订及风险注释:未完纪。原目录图来自原博客并保留原貌。
生成插件示例引用的GNU GPL Version 2完整文本
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.











暂无评论内容