模板:Custom rule
This template creates a rule made up of a number of interchangeable image segments.
Example
编辑{{Custom rule|sp|100|d|6|sp|10|d|10|sp|10|d|6|sp|100}}
Usage
编辑The parameters are a sequence of identifiers for the type of feature followed by that feature's width in pixels. These always form pairs of parameters. Below is a list of the features available. Update this list if you know of elements that are missing.
If an an identifier is not available for a segment you want, add it to {{custom rule segment}}, or use the plain identifier without a shorthand. Eg {{custom rule|sp|100}} = {{custom rule|Span|100}}.
The feature must be available as that specific size. If it is not, the image will not be found, and a red link will appear. You can see a full list at the Rule segments category at Commons. If you add your own segments, add them to this category.
Adding new feature types
编辑It is easy to add images to the set. In order to be found, the filename must be in the form "Rule Segment - [Identifier] - [Width]px.svg. Example: File:Rule Segment - Span - 10px.svg
Note that it is also required that the image meet up well at the sides. The rule is 1px wide, so the features must have a 1px edge on each side, in the exact centre (vertically) of the edge. To ensure this, run a 1px line through the feature so that it fills in the gaps. See the diagram on the left for an example of how this is done. Ensure that the line is aligned with the pixel grid (but not centred on it), otherwise it will come out blurry when rendered. To fix this, shift up or down by 0.5px. Be careful about edges of features as well, especially horizontal or vertical ones—these should be also aligned to pixel edges.
You will also need to add code to the template that grabs the image segments, {{Custom rule segment}}. Instructions on modifying that template can be found on the documentation there.
Adding more segments
编辑For complex rules, more segments can be added. Edit this template and paste in line in the format:
</noinclude>{{#if:{{{17|}}}|{{!!}}{{Custom rule segment|{{{17}}}|{{{18}}}}}}}<noinclude>
Make sure the numbers are continuous through the template, and that you match the first parameter of this line to the second one, otherwise the template will not render reliably.
See also
编辑- {{rule}} Simple rule of variable width - use this if you just want a line
- {{PSM rule}} Specific use of this template for use in Popular Science Monthly articles.
- {{separator}} for a row of dots:
· | · | · | · | · | · | · | · | · | · | · | · | · | · | · |
上述文档嵌入自Template:Custom rule/doc。 (编辑 | 历史) 编者可以在本模板的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。 本模板的子页面。 |