heredoc.js revision 802:235d22ccfd24
12341Scsgr#// Usage: jjs -scripting heredoc.js 22341Scsgr 32341Scsgr/* 42341Scsgr * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 52341Scsgr * 62341Scsgr * Redistribution and use in source and binary forms, with or without 72341Scsgr * modification, are permitted provided that the following conditions 82341Scsgr * are met: 92341Scsgr * 102341Scsgr * - Redistributions of source code must retain the above copyright 112341Scsgr * notice, this list of conditions and the following disclaimer. 122341Scsgr * 132341Scsgr * - Redistributions in binary form must reproduce the above copyright 142341Scsgr * notice, this list of conditions and the following disclaimer in the 152341Scsgr * documentation and/or other materials provided with the distribution. 162341Scsgr * 172341Scsgr * - Neither the name of Oracle nor the names of its 182341Scsgr * contributors may be used to endorse or promote products derived 192341Scsgr * from this software without specific prior written permission. 202341Scsgr * 212341Scsgr * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 222341Scsgr * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 232341Scsgr * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 242341Scsgr * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 252341Scsgr * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 262341Scsgr * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 272341Scsgr * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 282341Scsgr * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 292341Scsgr * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30216560Scharnier * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31216560Scharnier * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 322341Scsgr */ 3331488Scharnier 342341Scsgr// Nashorn supports Shell script like here-documents 3531488Scharnier// in -scripting mode. Here-docs are multi-line strings 362341Scsgr// that are possibly interpolated with ${} expressions 3731488Scharnier// See also http://en.wikipedia.org/wiki/Here_document 382341Scsgr 3931488Scharniervar sender = "Buffy the Vampire Slayer"; 4090868Smikevar recipient = "Spike"; 4131488Scharnier 4231488Scharnierprint(<<END 432341Scsgr 4431488ScharnierDear ${recipient}, 452341Scsgr 4631488ScharnierI wish you to leave Sunnydale and never return. 472341Scsgr 482341ScsgrNot Quite Love, 492341Scsgr${sender} 502341Scsgr 512341ScsgrEND); 522341Scsgr