0 of 1 found this page helpful

Automatically embed an attached file

    Table of contents
    No headers

    An easy way to share files, is to attach them to pages and then embed them directly into the wiki page itself.  The benefit is that it only requires someone to upload a new version of the file to automatically update the page as well.

    The following script checks if an attachment exists, and if does, embeds it using a syntax highlter.

    {{ 
        var files = map.values(page.files); 
        if(#files > 0) { 
            syntax.xml(web.text(files[0].uri))
        } else {
            "no file(s) attached"
        }
    }}
    

    Sample output:

    
            
     

    Was this page helpful?
    Tag page

    Files 1

    FileVersionSizeModified 
    Viewing 3 of 3 comments: view all
    Will this only work for text files? I need a way to display an existing document or spreadsheet.
    Posted 08:28, 1 Dec 2010
    @sperley to show other kinds of docs, you'll need an appropriate doc viewer for them. that aside, it will work then too
    Posted 09:27, 1 Dec 2010
    Thanks @SteveB. Any suggestions where to go for doc or spreadsheet viewers that will work in Mindtouch?
    Posted 13:29, 1 Dec 2010
    Viewing 3 of 3 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by