login | register
Wed 09 of Jul, 2008 [07:26 UTC]

voip-info.org

History

STS Template Engine

Created by: STS,Last modification on Tue 29 of Apr, 2008 [00:25 UTC] by gineta
Using the STS Template Engine to generate Asterisk configuration files

The STS Template Engine, developed by Sunrise Telephone Systems is a universal template engine for Cocoa featuring its own macro language for conditional template expansion. Although it can be used for any kind of template expansion requirement, it was developed for the purpose of generating Asterisk configuration files from templates.

The STS Template Engine is released under the GPL version 2 as Objective-C source code for embedding into Cocoa or GNUstep applications. A download link and detailed documentation is at this link is delete for SPAM to porno webs.

Overview


Methods provided

  • stringByExpandingTemplate:usingDictionary:errorsReturned:
  • stringByExpandingTemplate:withStartTag:andEndTag:usingDictionary:errorsReturned:
  • stringByExpandingTemplateAtPath:usingDictionary:encoding:errorsReturned:
  • stringByExpandingTemplateAtPath:withStartTag:andEndTag:usingDictionary:encoding:errorsReturned:

Macros supported

%IF, %IFNOT, %IFEQ, %IFNEQ, %IFDEF, %IFNDEF, %ELSIF, %ELSIFNOT, %ELSIFEQ, %ELSIFNEQ, %ELSIFDEF, %ELSIFNDEF, %ELSE, %ENDIF, %DEFINE, %UNDEF, %LOG, %ECHO and %DEBUG.

Predefined Placeholder Variables

_timestamp, _uniqueID, _hostname, _userCountryCode, _userLanguage, _systemCountryCode, _systemLanguage

Example template

%% Configuration template to generate X-Lite SIP profile for Asterisk
%% created 06-JUL-2005 by Sunrise Telephone Systems Ltd.
%% version 1.00
%%
%% The generated configlet must be included in /etc/asterisk/sip.conf
%%
%%
; THIS FILE HAS BEEN AUTOGENERATED %«_timestamp»
; DO NOT EDIT THIS FILE - MODIFICATIONS MAY BE OVERRIDDEN
;
;
[xlite] ; SIP profile for local X-Lite on %«_hostname»
port=5061
host=127.0.0.1
type=friend
qualify=no
reinvite=no
canreinvite=no
disallow=all
%IF allowUlaw
allow=ulaw
%ENDIF
%IF allowAlaw
allow=alaw
%ENDIF
%IF allowGSM
allow=gsm
%ENDIF
%IF allowILBC
allow=ilbc
%ENDIF
context=autocontext
callerid="%«username»"<%«callerid»>
;
%% END OF TEMPLATE

Example code

- (IBAction)createConfiglet:(id)sender {
       NSString *configlet;
       NSDictionary *userInput;
       NSArray *errorLog = [[NSArray alloc] init];
       
       // initialise the dicitionary with the user input
       userInput = [NSDictionary dictionaryWithObjectsAndKeys:
               [usernameField stringValue], @"username",
               [cidnumberField stringValue], @"callerid",
               [ringtimerField stringValue], @"ringtimer",
               [ulawCheckbox stringValue], @"allowUlaw",
               [alawCheckbox stringValue], @"allowAlaw",
               [gsmCheckbox stringValue], @"allowGSM",
               [ilbcCheckbox stringValue], @"allowILBC",
               nil];

       // expand the template to create the configlet
       configlet = [NSString stringByExpandingTemplateAtPath:
               @"/Library/Application Support/Asterisk/templates/xlite.template"
               usingDictionary:userInput
               encoding:NSUTF8StringEncoding
               errorsReturned:&errorLog];
       
       // etc

More Details

For a more detailed description please visit http://www.sunrise-tel.com/STSTemplateEngine.html


See also



Comments

Comments Filter
222

333

by SANDRY, Tuesday 12 of December, 2006 [12:05:45 UTC]
PLEASE DONT DO DAMAGE TO OTHERS
222

333

by SANDRY, Tuesday 12 of December, 2006 [12:02:10 UTC]
dear sir STS corporation we will appreciate if you can leave the name of Smart Network Solutions clean there is not proper behave to damage a corporation name just for the strong mistake but please do respect others trying to do proper business in the market if you need to write anyting to us our email is sales@smartisvoip.com we will be happy to talk also please do not place nazi things on our site we are serious people trying to do serious business