Difference between revisions of "Template:PrintFirstParagraph"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
<noinclude> | <noinclude> | ||
− | This template is used to extract the first paragraph from a given text. If the first paragraph of the text is longer than 1000 characters, only the first 997 characters are returned, and an ellipsis ( | + | This template is used to extract the first paragraph from a given text. If the first paragraph of the text is longer than 1000 characters, only the first 997 characters are returned, and an ellipsis (…) is added. |
'''NOTE:''' As any "printing" template, it doesn't store any values anywhere, but merely returns them. | '''NOTE:''' As any "printing" template, it doesn't store any values anywhere, but merely returns them. | ||
Line 13: | Line 13: | ||
-->{{#if: {{#var: varPos}}<!-- | -->{{#if: {{#var: varPos}}<!-- | ||
-->|<!-- if there are two or more paragraphs | -->|<!-- if there are two or more paragraphs | ||
− | -->{{# | + | -->{{#if: {{#expr: {{#var: varPos}} > 1000}}<!-- |
-->|{{#sub: {{{vartext|}}}|0|997}}<!-- | -->|{{#sub: {{{vartext|}}}|0|997}}<!-- | ||
-->|{{#explode_e: {{{vartext|}}}|\n|0}}<!-- | -->|{{#explode_e: {{{vartext|}}}|\n|0}}<!-- | ||
Line 21: | Line 21: | ||
-->{{#vardefine: varLen|{{#len: {{{vartext|}}} }}|}}<!-- | -->{{#vardefine: varLen|{{#len: {{{vartext|}}} }}|}}<!-- | ||
-->varlen={{#var: varLen}}<!-- | -->varlen={{#var: varLen}}<!-- | ||
− | -->{{# | + | -->{{#if: {{#expr: {{#var: varLen}} > 1000}}<!-- |
-->|greater{{#sub: {{{vartext|}}}|0|997}}<!-- | -->|greater{{#sub: {{{vartext|}}}|0|997}}<!-- | ||
-->|less{{{vartext|}}}<!-- | -->|less{{{vartext|}}}<!-- |
Revision as of 00:11, 15 March 2018
This template is used to extract the first paragraph from a given text. If the first paragraph of the text is longer than 1000 characters, only the first 997 characters are returned, and an ellipsis (…) is added.
NOTE: As any "printing" template, it doesn't store any values anywhere, but merely returns them.
Parameters:
|vartext=
- the text to extract the first paragraph from.