---
name: "MojoMojo::Formatter::File"
section: "3pm"
platform: "linux"
package: "libmojomojo-perl"
version: "1.12+dfsg-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/MojoMojo::Formatter::File"
---

# MojoMojo::Formatter::File(3pm)

format file as XHTML

## NAME

MojoMojo::Formatter::File - format file as XHTML

## DESCRIPTION

This formatter will format the file argument as XHTML.

Usage: {{file TYPE filename}}

```
       {{file Text uploads/Files/test.txt}}
```

TYPE is a plugin present in Formatter/File/ directory.

Currently there are only three: Pod, DocBook and Text

The plugin TYPE format only the file which the extension match with 'can\_format' method. Respectively pod, xml and txt for existing plugins.

For security reasons the path of file must be include in 'whitelisting' directory. You can use path\_to(DIR) to describe directory in mojomojo.conf:

Just an example to view the test pod file t/var/files/test.pod :

Add this to mojomojo.conf :

\<Formatter::Dir\>\
     prefix\_url /myfiles\
     whitelisting \_\_path\_to(t/var/files)\_\_ \</Formatter::Dir\>

To see the pod content formatted in xhtml, write in the text area:

{{file Pod path\_to(t/var/files)test.pod}}

To show recursively all files of directory see script/util/dir2mojomojo.pl script. To test it:

\# start mojomojo

./script/mojomojo\_server.pl

\# run dir2mojomojo script

./script/util/dir2mojomojo.pl --dir=~/dev/mojomojo/t/var/files/ --url=/myfiles

Connect to http://server:3000/myfiles/

## METHODS

- format\_content\_order

  Format order can be 1-99. The File formatter runs on 92.

- format\_content

  Calls the formatter. Takes a ref to the content as well as the context object.

- plugin

  Return the plugin to use with file attachment

- format

  Return the content formatted

- checkplugin

  Return 0 if plugin exist

- checkfile

  Directory must be include in whitelisting

## SEE ALSO

MojoMojo,Module::Pluggable::Ordered

## AUTHORS

Daniel Brosseau \<dab@catapulse.org\>

## LICENSE

This module is licensed under the same terms as Perl itself.
