Skip to content

Photoshop templating engine. Import json / csv data into your designs

Notifications You must be signed in to change notification settings

Aratramba/ps-barbershop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Barbershop

tested on Photoshop CS3, CS4 and CS5

So you want to import dynamic data into your psd's?

Getting started

1. Copy .jsx file

copy install/barbershop.jsx to your Photoshop scripts folder:

Windows: C:\Program Files\Adobe\Adobe Photoshop CS5\Presets\Scripts
Mac OS: Applications\Adobe Photoshop CS5\Presets\Scripts

2. Create variables

Create variables in your textlayers by wrapping them in double curly brackets, like so: {{variable}}. You can use object notation here if you wish, so {{object.object.key}} will work too (json only).

3. Run the script

Restart Photoshop.

Now run the script from the Photoshop menu under file › scripts › barbershop or go to file › scripts › browse and find barbershop.jsx.

A dialog should now appear where you can tweak some import settings. Import your file and all your variables will be magically replaced by their matching data.


Supported import formats

You can import CSV or JSON files with Barbershop.

CSV

CSV doesn't necessarily mean comma separated. Use commas, periods, semicolons or exclamation marks for all I care. Just make sure you set the right import setting for separator and string delimiter in the Photoshop dialog. Also don't forget to escape separator characters that should be interpreted as a cell values (e.g. value;"The semicolon (;) is a punctuation mark"; value).

name,textfield,
Barbershop,"some text",

Multiple rows will create multiple psd's.

name;textfield;
Barbershop;"some text";
"Barbershop II";"some text II";
JSON

Any JSON'ish file will do really.

Object

You can use a plain Javascript object:

{
    "name": {
        "firstname": "Barber",
        "lastname": "Shop"
    },
    "textfield": "some\ntext"
}
Array of objects

You can also use an array containing multiple objects. This will create multiple psd's.

[{
    "name": {
        "firstname": "Barber",
        "lastname": "Shop"
    },
    "textfield": "some\ntext"
},{
    "name": {
        "firstname": "Barber",
        "lastname": "Shop II"
    },
    "textfield": "some\ntext II"
}]
Functions

Javascript functions can be used as well. If a tag matches an executable function, that function will be executed. {{ fn }}

{
    fn: function(){
        return Math.random()
    }
}

To execute a function from another place in the json file, use its full path, and put quotes around it: {{ ref }}

{
    nested: {
        fn: function(){
            return Math.random()
        },
    },
    ref: "nested.fn()"
}

Pass arguments to a function {{ ref }}:

{
    fn: function(a,b){
        return a + b
    },
    ref: "fn(barber,shop)"
}

Use object properties for dynamic data {{ fn }}:

{
    prop: 0,
    fn: function(){
        return ++this.prop; // 1,2,3,4
    }
}

Why use it?

Defining Photoshops native variables and importing data sets can be quite a tedious task. Other than that you're very limited in what you can achieve with them. Plus your files get messy because of all the separate textlayers for your variables. Barbershop aims to simplify this process.


Known issues

CSV import error

Make sure all content, other than a single word or number, is wrapped in "" (or whatever the string_delimiter setting is set to). You'll get an error saying something like Delimiter expected after character x. (foo bar) if you don't "wrap strings in quotes".

Formatting removed

Barbershop will reset font styles if your textlayer consists of multiple text formats (like different colors, fonts, sizes etc). As long as you have 'plain' text fields, you're fine.


Tips

When you use a script often consider creating a shortcut.


Contribute

You must have node, npm, coffeescript and grunt installed.

Run npm install to create a local install of the grunt packages.

Run grunt to continually compile coffeescript and move the .jsx file to the photoshop directory. Set the proper directory in Grunfile.coffee file.

Report issues here.

About

Photoshop templating engine. Import json / csv data into your designs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages