Giter VIP home page Giter VIP logo

repeatjs's Introduction

RepeatJS

by Leonhard Pfob

How it works!

First you need to include the script. You can either use the way shown in the example or download and include it yourself.

(The file to download and include is located under "/src/compiled/repeat.min.js")

<html>
    <head>
        ...
        <script src="https://libs.3-klicks.de/repeat.min.js"></script>
        ...
    </head>
    ...
</html>

After we included the script we need to apply the attribute "repeat-element" with a numeric value to an element. This step could look something like this:

<h1 repeat-element="10">Hello World!!</h1>

In this case the header would be displayed 10 times. The expected output is:

<h1>Hello World!!</h1>
<h1>Hello World!!</h1>
<h1>Hello World!!</h1>
... 7 more times

Example 1 - Hello World

This is the way it would look, if you followed the instructions step by step:

<html>
    <head>
        <script src="https://libs.3-klicks.de/repeat.min.js"></script>
    </head>
    <body>
        <h1 repeat-element="10">Hello World!!</h1>
    </body>
</html>

Example 2 - Hello Planet

You can also use the repeat attribute in bigger structures. If a child element is repeatet and its parent, too, it will repeat the child element first and copy them in every repeation of the parent element.

Lets repeat a div with a header of mutiple subheaders.

<div repeat-element="3">
    <h1>Hello Planet!</h1>
    <h2 repeat-element="5">Hello World!</h2>
</div>

This would produce the following output:

<div>
    <h1>Hello Planet!</h1>
    <h2>Hello World!</h2>
    <h2>Hello World!</h2>
    <h2>Hello World!</h2>
    <h2>Hello World!</h2>
    <h2>Hello World!</h2>
</div>
... 2 more times

Example 3 - Repeating Texts

If you are trying different text lengths, you don't have to paste your text multiple times. Instead you can use the "repeat-text" attribute to copy texts.

<h1 repeat-text="3">Hello World!</h1>

The expected result is:

<h1>Hello World!Hello World!Hello World!</h1>

Purpose

"Why would I use this?" you might ask. Developing a web application you usually don't include the logic right away, but focus on getting all your elements ready. If you use example elements, you often have to copy them. If you change something up, you have to do so for every single one. Instead, you could use repeat.js, which helps you avoid this issue and stay organized.

repeatjs's People

Contributors

leopf avatar leopv1 avatar

Forkers

deawx

repeatjs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.