Last active
August 10, 2021 19:32
-
-
Save batazo/c96543ad7b92e74d5e1f87dc9519f2b8 to your computer and use it in GitHub Desktop.
User Template with BIND
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="userwelcomeDiv"> | |
| {{ User Welcome Panels loading... }} | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let users = [ | |
| {name: "Zoltán", city: "Budapest"}, | |
| {name: "Éva", city: "Debrecen"}, | |
| {name: "István", city: "Kecskemét"}, | |
| {name: "Katalin", city: "Szeged"}, | |
| {name: "János", city: "Sopron"}, | |
| {name: "Fanni", city: "Tatabánya"} | |
| ] | |
| console.table(users) | |
| function welcomePanel(name, city) { | |
| let welcomeTemplate = function () { | |
| return `<div class="welcomePanels">Welcome here <span class="green">${this.name}</span> from ${this.city}!</div>`; | |
| }; | |
| let welcomeuser = welcomeTemplate.bind({ | |
| name: name.toUpperCase(), | |
| city: city | |
| })(); | |
| return welcomeuser | |
| } | |
| function renderWelcomePanels(){ | |
| userwelcomeDiv.innerHTML = "" | |
| for(let user of users){ | |
| userwelcomeDiv.innerHTML += welcomePanel(user.name, user.city) | |
| } | |
| } | |
| renderWelcomePanels() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .welcomePanels { | |
| margin: 10px; | |
| padding: 10px; | |
| border: 3px solid darkgray; | |
| background-color: lightgray; | |
| } | |
| .green { | |
| color: green; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment