During the development of website templates, we often encounter such a situation: the interface layout has been completed, but the actual content data is not ready.This is to ensure that the layout and visual effects of the front-end page are presented accurately, we need some placeholder text to fill the page and simulate the existence of real content.loremIt can help us easily generate a specified number of random texts.

loremTags: A good helper for template development

loremThe original intention of label design was to solve the problem of filling template content.It can quickly generate standard 'Lorem Ipsum' placeholder text that has no real meaning, but whose word and sentence structure is similar to natural language. It is very suitable for testing the font, line height, paragraph spacing, and other visual elements of web pages, and avoids layout distortion due to the lack of content.

UseloremTags, you can quickly insert placeholders in the article detail page, product description area, sidebar introduction, or any other place where text content is required, thus focusing more on the style and interaction logic of the template without worrying about the lack of actual content to fill the page.

loremThe detailed usage of tags

loremThe syntax of tags is very concise, but the functionality is sufficiently flexible, meeting the needs of different scenarios.

1. Generate the default Lorem Ipsum text

If you just need a standard placeholder text without caring about the specific length or format, you can directly use it without any parameters.loremTags:

{% lorem %}

Execute this code, and the template will output a longer, standard Lorem Ipsum paragraph of text.This is very convenient for quickly previewing the overall effect of a text block.

2. Specify the number and unit of the generated text.

loremTags allow you to precisely control the number of generated text. You can specify the quantity through the second parameter, and define the unit of this quantity through the third parameter (method):

  • Generate by word count (w)You can use it as a method parameter when you want to generate a specific number of words.wFor example, to generate 10 words:

    {% lorem 10 w %}
    

    This will output a text consisting of 10 Lorem Ipsum words in the template.

  • Generate by number of paragraphs (p)If your placeholder needs to simulate multiple paragraphs, you can usepas a method parameter. For example, to generate 3 paragraphs:

    {% lorem 3 p %}
    

    The generated text will contain at this point<p>Tags, simulate real HTML paragraph structure, which is particularly useful for testing paragraph spacing and styles.

3. Increase the randomness of text.

By default,loremThe content generated by the tag is always the same. If you want to see different placeholder text each time the page is refreshed to fully test the responsiveness and layout compatibility of the page, you can addrandomParameters:

{% lorem 10 w random %}

or:

{% lorem 3 p random %}

Addrandomafter the parameter, each time you visit the page,loremthe tag will generate a new, randomly combined Lorem Ipsum text, making your test scenario more diverse.

Actual application example

Assuming you are developing a template for an article detail page, which includes the article title, introduction, and body. In the absence of actual article data, you can utilize it like this:loremTags to fill:

<article>
    <h1>这是文章标题占位符</h1>
    <p class="summary">
        {% lorem 30 w %} <!-- 模拟文章简介,生成30个单词 -->
    </p>
    <div class="content">
        {% lorem 5 p random %} <!-- 模拟文章正文,生成5个随机段落 -->
    </div>
</article>

In this way, you can clearly see the approximate layout of the page before the actual content is ready, and adjust the style in time.

loremTags are a low-profile yet efficient member of the AnQi CMS template development toolkit, greatly facilitating front-end development and template debugging, allowing you to focus more on user experience and page aesthetics.


Common Questions and Answers (FAQ)

  1. loremDoes the text generated by the tag always stay the same?By default,loremThe text generated by the tag is fixed standard Lorem Ipsum content. If you want to generate different random text each time the page is refreshed, you can addrandomparameters, such as{% lorem 10 w random %}.

  2. loremCan the tag generate placeholder text in Chinese or other languages? loremTags are specifically used to generate standard 'Lorem Ipsum' Latin text samples, therefore it currently does not support generating placeholder text in Chinese or other natural languages.If you need placeholders in a specific language, you may need to copy and paste manually or write custom text snippets.

  3. If I need a more complex HTML structure as a placeholder,loremcan the tag achieve that? loremTags are mainly used to generate plain text or paragraphs containing<p>tags. If you need to simulate more complex HTML structures, such as including images, links, lists, etc., you need toloremLabel embedded into the HTML structure you manually write.loremThe label itself does not automatically generate complex HTML elements.