Coder Social home page Coder Social logo

Feature: Iteration about plates HOT 3 CLOSED

flatiron avatar flatiron commented on June 12, 2024
Feature: Iteration

from plates.

Comments (3)

mwawrusch avatar mwawrusch commented on June 12, 2024

+1

I am trying to come up with a good syntax for this. My gut feeling tells me that we should do something like

data-bind='name of array/object to iterate' data-each="name of template'

as a control structure in the html. Plates would basically invoke a custom callback, passing the name of the template, the data object that is in scope, the name and some way to inject text in the rendering stream. The plates consumer could then instantiate a new plates with the template name specified, render the sub template x times, append it to the primary templates output and voila, everyone is happy.

from plates.

heapwolf avatar heapwolf commented on June 12, 2024

@mwawrusch, that goes against the entire concept of the library. html and data MUST be on the passive/receiving end of things. or else its just as bad as any other DSL-dependent templating lib. iteration should be drivin be the data...

javascript

  var html = '<div id="test"></div>';
  var data = { "test": ["First Value", "Second Value"] };

  var output = Plates.bind(html, data);

html output

  <div id="test">First Value</div><div id="test">Second Value</div>

from plates.

 avatar commented on June 12, 2024

@hij1nx: Great solution! Keeps the HTML prettier :)

from plates.

Related Issues (20)

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.