Name

write-relative-file — save content to a filename inside the catalog directory

ATTRIBUTES

Attribute Pos. Req. Default Description
file Yes Yes Pathname to write to, relative to CATROOT.
auto_create_dir     0 Auto-create directories in the file path?
umask       File creation umask.
interpolate     0 interpolate input?
reparse     1 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

The tag writes a file in the catalog directory. File name is subject to file control (e.g. it must be relative), it will return undef if the check isn't passed.

If the file exists, it is truncated (file contents get overwritten, not appended).

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

Example: Simple file write

[write-relative-file logs/test]Sample content[/write-relative-file]

NOTES

AVAILABILITY

write-relative-file is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: code/UI_Tag/write_relative_file.coretag
Lines: 26


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: write_relative_file.coretag,v 1.10 2007-03-30 23:40:54 pajamian Exp $

UserTag write-relative-file Order         file
UserTag write-relative-file hasEndTag
UserTag write-relative-file addAttr
UserTag write-relative-file Version       $Revision: 1.10 $
UserTag write-relative-file Routine       <<EOR
sub {
my ($file, $opt, $data) = @_;
#::logDebug("writing $file");
unless(defined $data) {
  $data = $opt;
  $opt = {};
}
return undef unless Vend::File::allowed_file($file, 1);
$opt->{auto_create_dir} = 1 unless defined $opt->{auto_create_dir};
Vend::File::writefile(">$file", $data, $opt);
}
EOR

AUTHORS

Interchange Development Group

SEE ALSO

unlink_file(7ic)

DocBook! Interchange!