Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Add support for object paths in target (+ 2 new object functions)#50

Merged
arguiot merged 5 commits into
arguiot:masterfrom
limiter121:target-path
May 17, 2018
Merged

Add support for object paths in target (+ 2 new object functions)#50
arguiot merged 5 commits into
arguiot:masterfrom
limiter121:target-path

Conversation

@limiter121

Copy link
Copy Markdown

Added support for using object paths (like myobj.a.b.c) as target.

Example:

<input target="person.address.city" placeholder="Where is Kevin from?">
<p var="person.address.city"></p>
// Create a var for Display.JS. You don't have to add the $ var, you can change the name.
var $ = new DisplayJS(window);
// Create an object 'person' who's name is 'Kevin', and he lives in New York.
var person = {name: 'Kevin', address: {city:'New-York'}};
// Rendering the DOM
$.var();
$.target();

Also added 2 new functions getAtPath, setAtPath for use with objects and paths.

Example:

var $ = new DisplayJS(window);
var person = {name: 'Kevin', address: {city:'New-York'}};

// Get value at path
console.log($.getAtPath(person, 'address.city')) // Output: New-York

// Set value at path
$.setAtPath(person, 'address.city', 'San-Francisco')
console.log($.getAtPath(person, 'address.city')) // Output: San-Francisco

@CLAassistant

CLAassistant commented May 17, 2018

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@arguiot

arguiot commented May 17, 2018

Copy link
Copy Markdown
Owner

Thank you very much for that. I’m trying to fix Travis build before merging. Nice 👍 work.

@arguiot arguiot merged commit 5d57914 into arguiot:master May 17, 2018
@arguiot

arguiot commented May 17, 2018

Copy link
Copy Markdown
Owner

I’ll try to create a release as soon as possible. But because DisplayJS isn’t my main project right now, I can’t guarantee that I’ll be able to release it this week.

If you’re interested in DisplayJS, you should checkout my new framework that is still in development: https://protype.js.org

@limiter121 limiter121 deleted the target-path branch May 18, 2018 15:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants