Link | file_pathfromroot |
Author | Jason Huck |
Category | File |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 26 Oct 2005 |
Updated | 16 Jan 2006 |
More by this author... |
Converts a relative path to a root path.
file_pathfromroot('../../images/foo.gif'); -> /images/foo.gif
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag( 'pathfromroot', -namespace='file_', -priority='replace', -description='Converts a relative path to a root path.' ); fail_if( !params->size || !params->first->isa('string'), -1, '[file_pathfromroot] requires a file path as a parameter.' ); local('in' = params->first); if(#in->beginswith('/')); return(#in); else(#in->beginswith('../')); local('steps' = #in->split('../')->size - 1); local('out' = '/'); iterate(response_path->split('/'), local('i')); loop_count > 1 ? #out += #i + '/'; loop_count == #steps ? loop_abort; /iterate; #out += #in; return(#in); else; return(response_path + #in); /if; /define_tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft