AnQiCMS as an enterprise-level content management system developed based on the Go language, with its high efficiency, customizable and easy to expand features, provides great convenience for content operators.In the process of daily website content creation and template design, we often need to quickly fill in placeholder text to test the layout and style effects of the page.loremTags can fully demonstrate their capabilities. This article will delve into the details.loremThe default behavior of tags, 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 situations: the core content is not ready, but the page layout, text layout, and the coordination effect between images and text all need to be tested in advance.If manual input of a large amount of meaningless text is performed, it is inefficient and prone to errors.loremLabels are created to solve this pain point, they can quickly generate "Lorem Ipsum" type classic Latin text sample data.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 issues.
UnderstandingloremLabel's default behavior
When we use the template directly in AnQiCMSloremthe tag without any parameters, it will display its most basic default behavior.
For example, you just need to write down:
{% lorem %}
Or, even if you try to follow a number after aloremtag without specifying the type of content (such as awword or paragraphp),its default behavior still 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, contains detailed content, and is sufficient to fill most conventional text areas.Its main purpose is to provide a sufficient text block, allowing you to fully assess the page layout's performance with longer content.This means that, whether you specify a number or not, as long as it is not explicitly stated whether a word or a paragraph is generated, the system will default to providing a complete, preset text block.
CustomizationloremOutput of label content
Although the default behavior is very convenient, in actual development, we often need to control it more finelyloremThe number and type of content generated by tags. AnQiCMS provides concise 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 the number after itw(abbreviation for 'words') parameter.
For example, to generate 20 words:
{% lorem 20 w %}
This code will output a "Lorem Ipsum" phrase containing 20 words, which is very suitable for filling brief description or label areas.
Generate a specified number of paragraphs
If your requirement is to generate multiple paragraphs to simulate the structure of articles or product details and longer content, you can usep(the 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 article content.
Introducing randomness in content inclusion
In addition to a fixed number of texts, we may also need the generated text to be different each time to avoid repetition and enhance the authenticity of the test. At this point, one can introducerandomParameter.
For example, generate 10 random words:
{% lorem 10 w random %}
AddrandomAfter the parameter, the generated text content will be randomly combined from the "Lorem Ipsum" library each time the page is loaded, ensuring that the output of the content is unique each time.
loremThe combination of labels with other template functions
loremThe strength of the label not only lies in its independent generation capability, but also in its seamless integration with other template labels 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 astruncatechars(truncated by character) ortruncatewords(auto cut by word)。
Suppose you want to generate a text containing 50 words, but only display the first 30 characters and end with an ellipsis:
{% filter truncatechars:30 %}
{% lorem 50 w %}
{% endfilter %}
In this way,loremThe long text generated by tags will betruncatecharsFilter processing, only display the exact length you need, ensuring the uniformity of the layout, and 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:
- Rapid prototyping design:At the beginning of the project, it can be used
loremQuickly fill the page, focusing on layout and interaction design. - Template development test:Ensure that the article list, detail page, comment area, etc. can be displayed correctly whether there is actual content or not, and check for issues such as text overflow and line breaks.
- Multilingual adaptation simulation:With multi-language support, quickly test the impact of different language text length on layout.
**Practice reminder:**AlthoughloremLabels are a developer's best friend, but be sure to replace them with real, meaningful content before the website goes live.Placeholder text is convenient, but it does not help with the website's SEO or user experience.It is just a temporary 'scaffolding', which should be removed as soon as the content is in place.
Through the introduction of this article, I believe you have already understood the AnQiCMS inloremTags default behavior and extensive customization options are fully understood. Properly utilizing this tool will significantly enhance your website development efficiency and template debugging experience.
Common 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. As well asfilter:truncatechars(and similar to)truncatewords) is aFilter,Its function is to truncate the existing string (whether it is real content or generated content), and add ellipses as needed. In simple terms,loremit is responsible for “has”,lorem负责“有”,truncatecharsResponsible for "trimming". They can be used together, first usingloremto generate content, and then using filters to shorten the length.
2.loremTagsrandomHow do parameters affect the content?
When you areloremthe label userandomthe parameter (for example){% lorem 10 w random %}),The system will not sequentially take content from a 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 vary each time the page is loaded or refreshed, which is very useful for testing the adaptability of the layout to different text combinations.randomparameters,loremThe label will generate the same and predictable text fragments.