AnQiCMS is an enterprise-level content management system developed based on the Go language, which provides great convenience for content operators with its high efficiency, customizable and easy-to-expand features.In the process of creating website content and template design, we often need to quickly fill in some placeholder text to test the layout and style effects of the page.At this time, AnQiCMS built-in theloremTags can fully display their prowess. This article will delve deeper into it.loremTags' default behavior, and guide you on how to flexibly use it to meet various content filling needs.

loremTags: a powerful assistant for front-end development.

When designing and developing website templates in front-end, we often encounter such a situation: the core content is not ready, but the page layout, text layout, and the coordination effect between images and text need to be tested first.If manual input of a large amount of meaningless text is done, it is inefficient and prone to errors.loremThe label is born to solve this pain point, it can quickly generate classic Latin sample data like 'Lorem Ipsum'.This not only helps designers and developers preview the page effect intuitively, but also ensures the diversity of content length and format, thus better discovering potential layout problems.

UnderstandingloremThe default behavior of the tag

When we use the tag directly in the AnQiCMS templateloremwithout any parameters, it will display its most basic default behavior.

For example, just simply write:

{% lorem %}

Or even if you try toloremFollow a number after the tag without specifying the type of content (such as a wordwOr paragraphp),its default behavior remains unchanged:

{% lorem 10 %}

In the above two cases, AnQiCMS will automatically generate a standard-length "Lorem Ipsum" text, which is usually composed of multiple paragraphs, detailed content, and is enough to fill most conventional text areas.Its primary purpose is to provide a sufficient text block to allow you to fully assess the page layout's performance when facing longer content.This means that whether or not you specify a number, as long as it is not explicitly stated whether a word or a paragraph is to be generated, the system will default to providing a complete, preset text block.

customizedloremLabel content output

Although the default behavior is very convenient, in actual development, we often need to control it more finelyloremLabel the quantity and type of generated content. AnQiCMS provides simple and powerful parameter options for this.

Generate a specified number of words

If you want to generate a specific number of words, you can add it after the number.w(Abbreviation of 'words') parameter.

For example, to generate 20 words:

{% lorem 20 w %}

This code will output a phrase containing 20 words of 'Lorem Ipsum', which is very suitable for filling short descriptions or label areas.

Generate a specified number of paragraphs

If your requirement is to generate multiple paragraphs to simulate the structure of longer content such as articles or product details, you can use thep(abbreviation of paragraphs) parameter.

For example, to generate 3 paragraphs:

{% lorem 3 p %}

In this way, you will get 3 independent 'Lorem Ipsum' paragraphs, each one by:<p>Label wrapping (the specific structure of the label depends on your template engine configuration and content security settings), which can better test the block layout of the article content.

Introducing randomness in the content.

In addition to a fixed number of texts, we sometimes need the generated text to be different each time to avoid repetition and enhance the authenticity of the test. At this point, we can introducerandomParameter.

For example, generate 10 random words:

{% lorem 10 w random %}

addrandomAfter the parameter, every time the page is loaded, the generated text content will be randomly combined from the "Lorem Ipsum" library, ensuring that each output has a certain uniqueness.

loremThe combination of tags with other template functions

loremThe power of tags is not only in their independent generation ability, but also in their seamless integration with other template tags and filters of AnQiCMS, enabling more complex application scenarios.

For example, you may need to generate a placeholder text but also want to strictly control its display length to fit a fixed-width UI component. In this case, you can combine the use of filters such astruncatecharsCharacter truncate ortruncatewords(Break words).

Suppose you want to generate a text with 50 words, but only display the first 30 characters and end with an ellipsis:

{% filter truncatechars:30 %}
    {% lorem 50 w %}
{% endfilter %}

By this means,loremThe long text generated by the tag will first betruncatecharsFilter processing, only displaying the exact length you need, ensuring the regularity of the layout, while also previewing the user experience after content truncation.

Application scenarios and **practice

loremThe application scenarios of tags in AnQiCMS are very extensive, mainly focusing on the following aspects:

  1. Rapid prototyping design:In the early stage of the project, you can useloremQuickly fill the page, focusing on layout and interaction design.
  2. Template development test:Ensure that the article list, detail page, comment area, etc. are displayed correctly with or without actual content, check for issues such as text overflow and line breaks.
  3. Multilingual adaptation simulation:Cooperating with the multilingual function, quickly test the impact of different language text length on layout.

**Practical reminder:ThoughloremLabels are a developer's tool, but they must be replaced with real and meaningful content before the website goes live.Placeholders are convenient, but they do not help the SEO or user experience of the website.It is just a temporary 'scaffolding', and it should be removed in time after the content is in place.

Through the introduction of this article, I believe you have already understood the AnQiCMSloremA comprehensive understanding of the default behavior and rich customization options of the tag. Proper use of this tool will significantly improve your website development efficiency and template debugging experience.


Frequently Asked Questions (FAQ)

1.loremTags andfilter:truncatecharsWhat is the difference?

loremThe main function of the label isgenerateRandom placeholder text content. It provides a text source, where you can specify the number of words or paragraphs to generate. Andfilter:truncatechars(and similar to)truncatewords)is aFilterIt is used to truncate an existing string (whether it is real content orloremgenerated content) and add an ellipsis as needed. In simple terms,loremresponsible for “having”,truncatecharsResponsible for "trimming". They can be used together, first usingloremto generate content, and then using a filter to shorten the length.

2.loremlabel'srandomHow do parameters affect the content?

when you areloremUsed in tagsrandomparameters, for example{% lorem 10 w random %}), the system will not extract content in order from the fixed 'Lorem Ipsum' text block, but will randomly select and combine from a preset phrase or word library.This means that the generated text content may differ each time the page is loaded or refreshed, which is very useful for testing the layout's adaptability to different text combinations.If notrandomparameter,loremLabels will generate the same and predictable text fragments.