Attribute substitution for iterative object #64

Open
joncostello opened this Issue Apr 22, 2012 · 4 comments

Projects

None yet

3 participants

@joncostello

I can't find documentation or a test for this anywhere.

I am trying to substitute a value of an object in an array as the value of an attribute(href). Not sure if it's not supported or if I just can't find how to map it

I've tried variations along the lines of:
map.where('href').has('id').insert('items.id')

for the html/json in this gist:
https://gist.github.com/2467056

@fiatjaf

Did you solved this?

@davidamitchell

something like the below will work:

 var plates = require('plates');

 var markup = '<div class="people"><a class="person" href="person/id"></a></div>';
 var data = {
         people: [
                 {
                         id:'1',
                         name:'bob'
                 },      
                 {
                         id:'2',
                         name:'sue'
                 }       
         ]       
}       
var map = new plates.Map();
map.class('people').use('people');
map.class('person').use('name');
map.where('href').has(/id/).insert('id');

console.log(plates.bind(markup, data, map));
@fiatjaf

It doesn't. Here Plates appended a.innerText with the contents of id.

@davidamitchell

what was your output? below is what i get:

<div class="people"><a class="person" href="person/1">bob</a></div><div class="people"><a class="person" href="person/2">sue</a></div>

using plates v0.4.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment