Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute substitution for iterative object #64

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

Attribute substitution for iterative object #64

joncostello opened this issue Apr 22, 2012 · 4 comments

Comments

@joncostello
Copy link

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
Copy link

fiatjaf commented Dec 11, 2013

Did you solved this?

@davidamitchell
Copy link

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
Copy link

fiatjaf commented Dec 12, 2013

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

@davidamitchell
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants