GarageSale Template Language

From GarageSaleWiki

Jump to: navigation, search

GarageSale will distinguish between HTML and macro language commands using double square brackets. That means macro language commands have to be embedded in between [[ and ]] characters.

Commands from the macro language can be used in a Design Templates HTML text and in the Item Description field.

Contents

Object placeholders

Some of the macro commands are placeholders that are substituted with objects when a design template is applied to an auction description. If a placeholder refers to a string object (e.g. [[description]]) it will be replaced with that string. If it refers to another kind of object you can use a dot operator to access properties of the referred object, e.g [[item.title]].

Control Statements

The second type of macro language commands are control statements. Use these to different parts of HTML in your auction description depending on certain conditions. For example, use if for conditionals or for” loops to control the number of images in the auction.

If Statements

An if statement in GarageSale's macro language has the form [[if condition]] <code to include>[[else]] <alternate code to include> [[endif]]. The code between the the if and endif commands will only be included in your auction template if 'condition' is true, or the object it refers to is defined. Here is an example if statement that only includes an item's subtitle if the user provided one:


[[if item.subTitle]]
    <h3>[[item.subTitle]]</h3>
[[endif]]

Foreach Statements

A foreach statement can include additional text in your template for each item in a list, for example for each image in your auction. A foreach loop has the form [[foreach item itemList loopIdentifer]]<code to include>[[endforeach loopIdentifier]], where item is used to reference an item contained in itemList each time the foreach loop is reiterated. The loopIdentifier is used to match foreach and endforeach commands when you nest several loops. Here is an example foreach statement that includes a HTML image reference for each auction image:

[[foreach image item.auctionImages imagesMainLoop]]
    <a name="[[image.anchor]]"><img src="[[image.imageURL]]"><br>
[[endforeach imagesMainLoop]]

Since you would only want to include such a foreach loop if the user is not using eBay's picture service, it's a smart idea to check the current server setting:

[[if preferences.useOwnServer]]
	[[foreach image item.auctionImages imagesMainLoop]]
     	<a name="[[image.anchor]]"><img src="[[image.imageURL]]"><br><br>
	[[endforeach imagesMainLoop]]
[[endif]]

Accessing Single Auction Image URLs

You can use the [[index item.auctionImageURLs i]] statement to directly access certain image URLs. Substitute i with the index of the auction image whose URL you want to include. Please note that the first image has the index 0, the second one has the index 1, and so on. This code snippnet would include the first image directly in your auction description.

<img src="[[index item.auctionImageURLs 0]]">

Testing whether an auction image index is valid

For some design templates it might be necessary to test wether the auction template contains a second image before including certain code parts in the generated HTML file. You can test wether an auction image at a certain index exists using this syntax: [[if "index item.auctionImageURLs i"]], where i is the index you are testing for. Please remember that image index counting starts a 0.

The example code below only includes HTML code for the second image if it exists:

[[if "index item.auctionImageURLs 1"]]
     <div style="border: solid 1px #333;">
     <img src="[[index item.auctionImageURLs 1]]" width="180" border="0">
     </div>
[[endif]]

This feature only works for GarageSale 2.1 and above. If you are using the Design Template Utility to create your template please set the Min. GS Version popup accordingly.

Adding Shipping Information to your listing

If you enabled calculated shipping for your item, you can include the information you entered in GarageSale's shipping panel in your design template. Use the shipping option properties described above in the Shipping Options Properties table to insert weight and dimensions in your auction description.

 [[if item.shippingOptions.usesCalculatedShipping]]
	<b>Shipping Dimensions: </b><br>
	Weight: [[item.shippingOptions.packagePounds]] lbs 	
		 [[item.shippingOptions.packageOunces]] <br>
	Dimension:[[item.shippingOptions.packageWidth]] x 
		   [[item.shippingOptions.packageLength]] x 
			 [[item.shippingOptions.packageDepth]] <br>
 [[endif]]

For more code examples feel free to dig around in GarageSale's built-in design templates directory.

Placeholders

Design Template Placeholders

The following placeholders can use be inside a design template's body.html file.

Placeholder Name String Value
[[description]] String The description of the current auction template.
[[item]] Auction Item A reference to current item.
[[preferences]] Preferences A reference to GarageSale preferences.

Auction Template Properties

The individual properties of an auction template can be accessed using these placeholders:

Property Name Type Value
[[item.title]] String The auction title.
[[item.subTitle]] String The auction subtitle.
[[item.minimumBid]] String The minimum or starting bid for the auction.
[[item.duration]] String The minimum or starting bid for the auction.
[[item.checkoutInstructions]] String Additional checkout instructions for the item.
[[item.location]] String The location string for an item.
[[item.auctionImages]] List of Images List contains all images of the auction.
[[item.auctionImageURLs]] List of Strings List contains all URLs of the images included in the auction.
[[item.shippingOptions]] Shipping Options Shipping options.

Image Properties

The individual properties of an image can be accessed using these placeholders:

Property Name Type Value
[[image.anchor]] String A unique string that can be used to create HTML anchor and links to those anchors.
[[image.imageURL]] String The URL under which the item is stored.
[[image.thumbWidth]] String Returns either 180 or 135 depending on the image's orientation (landscape or portrait). Will always be 180 for URL based auction images.
[[image.thumbHeight]] String Returns either 135 or 180 depending on the images orientation (landscape or portrait). Will always be 135 for URL based auction images.

Preferences Properties

Use the preference object to query GarageSale preferences settings:

Property Name Type Value
[[preferences.useOwnServer]] Boolean True if images are stored on users own server, false if the eBay's Picture Server is used.

Shipping Options Properties

You can use the properties of the Shipping Options to include information about your shipment in your auction description.

Property Name Type Value
[[shippingOptions.usesCalculatedShipping]] Boolean True if you have enabled Calculated Shipping in GarageSale's Shipping Options panel for the item.
[[shippingOptions.packagePounds]] String Package Pounds
[[shippingOptions.packageOunces]] String Package Ounces
[[shippingOptions.packageDepth]] String Package Depth
[[shippingOptions.packageWidth]] String Package Width
Personal tools