Generate random text of a specified length as placeholder content in AnQiCMS template.
During website development and content operations, we often encounter scenarios where placeholder content (Placeholder Content) needs to be filled in.Whether it is designing a new template, testing page layout, or providing an initial preview when the content is not yet fully ready, placeholder text helps us quickly build prototypes, intuitively assess visual effects, and fill in the real content without waiting.
The AnQiCMS template system is very powerful, it supports Django-like template engine syntax, allowing us to flexibly control page layout and content display. Among them, there is a very practical tag -loremUsed to quickly generate random text of a specified length in templates.
Get to knowloremLabel: The magician of placeholder text.
loremThe tag is an auxiliary function provided by the AnQiCMS template engine, which is mainly used to quickly generate a segment of meaningless Latin-style text in the template, which is what we commonly call 'random dummy text' or 'placeholder text'.The design of this label is to facilitate developers and content editors so that they can fill the page and test the layout effect even when there is no actual content.
UseloremWhen labeling, you can adjust the number and form of generated text as needed. It provides several parameters to precisely control the output:
Quantity (Quantity)This parameter is used to control the length of the text you want to generate.It can be a number representing the number of words, paragraphs, or characters you want, depending on the "method" parameter you choose.
Method (Method)This is
loremOne of the core tags, which determines the meaning of the "quantity" parameter. AnQiCMS supports the following three main methods:w(words, word)If you want to generate a specified number of words, usewFor example,{% lorem 10 w %}It will generate 10 random words.p(paragraphs, paragraphs)Select when you need to generate a specified number of paragraphs.pFor example,{% lorem 3 p %}It will generate placeholder text for 3 paragraphs.b(bytes/characters, bytes/characters)If you need to generate text at the byte or character level, you can useb. In most layout test scenarios of Chinese content websitesworpit will be more intuitive and commonly used.
random(Is it random)This is an optional parameter. If you add it at the end of the tagrandomThen, every time the page is loaded, the generated text content may vary. This is useful for simulating dynamic content changes or avoiding visual fatigue. If omittedrandomThis will generate a fixed standard Lorem Ipsum text snippet, which is particularly useful in ensuring the consistency of test content.
Actual operation: How to use in the templateloremTag
Here are some practical applicationsloremAn example of a tag, to help you better understand how to use it in the template:
Generate a specified number of random words:Suppose you only need to fill in a short paragraph in a card or list item, such as 15 words, you can write it like this:
<div class="card-description"> <p>{% lorem 15 w %}</p> </div>This will generate 15 words of Latin placeholder text in this paragraph.
Generate a specified number of paragraphs:If you need to fill the article main content area, and hope to have a structure with multiple paragraphs, such as 2 paragraphs, you can do it like this:
<div class="article-content"> {% lorem 2 p %} </div>This will output two independent, with
<p>Label placeholder text, very suitable for testing the overall layout of the article page.Generate standard content of fixed length (default mode):If you do not specify
数量and方法parameter,loremThe tag generates a standard-length Lorem Ipsum text. If you need random content every time it loads, you can addrandomparameters:<p>固定占位内容:{% lorem %}</p> <p>每次刷新都随机:{% lorem random %}</p>When no parameters are provided, the output is a complete Lorem Ipsum standard paragraph, and when
randomit will randomly select from a preset number of standard paragraphs.Mix and precise control:You can flexibly combine these parameters according to your specific needs. For example, generate 50-word text and require that the content be different each time the page is refreshed:
<div class="product-summary"> <h4>产品亮点:</h4> <p>{% lorem 50 w random %}</p> </div>This is very convenient when filling a large amount of description text on the product details page, but it is very convenient when the copy has not been finally determined.
Usage scenarios and practical tips
loremThe tag is especially useful when developing website templates, planning initial content, or testing page layouts. It can help you:
- Rapid prototyping:When the real content is not in place, use placeholder text to quickly view the page structure and style effects, improving development efficiency.
- Test responsive layout: Check whether the content can adapt and display well under different screen sizes with placeholder text of varying lengths.
- Simulated content lengthSome content blocks need specific length of text to display **effect,
loremThe tag can accurately simulate this requirement. - Avoid the feeling of 'no content'At the stage when the content is still being created, make the page look less empty