diff --git a/jruby/pom.xml b/jruby/pom.xml deleted file mode 100644 index fed3827e07..0000000000 --- a/jruby/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - 4.0.0 - - org.kohsuke.stapler - stapler-parent - ${changelist} - - - stapler-jruby - Stapler JRuby module - JRuby binding for Stapler - - - - org.apache.maven.plugins - maven-surefire-plugin - - ${skip.jruby.tests} - - - - - - - ${project.groupId} - stapler-jelly - ${project.version} - - - org.jruby - jruby-complete - 1.7.17 - - - org.jruby.rack - jruby-rack - 1.1.21 - - - javax.servlet - javax.servlet-api - 3.1.0 - provided - - - org.jvnet.hudson - commons-jelly-tags-define - test - - - dom4j - dom4j - - - commons-cli - commons-cli - - - org.jvnet.hudson - commons-jelly - - - - - ${project.groupId} - stapler - ${project.version} - tests - test - - - junit - junit - test - - - org.kohsuke.metainf-services - metainf-services - true - - - org.mockito - mockito-core - test - - - org.jenkins-ci - test-annotations - test - - - org.hamcrest - hamcrest - test - - - - true - ${skipTests} - - diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/AbstractRubyTearOff.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/AbstractRubyTearOff.java deleted file mode 100644 index 20ff2fe404..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/AbstractRubyTearOff.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.apache.commons.jelly.Script; -import org.kohsuke.stapler.AbstractTearOff; -import org.kohsuke.stapler.MetaClass; -import org.kohsuke.stapler.WebApp; -import org.kohsuke.stapler.jelly.JellyRequestDispatcher; - -import javax.servlet.RequestDispatcher; -import java.io.IOException; -import java.net.URL; - -/** - * - * - * @author Kohsuke Kawaguchi - */ -public abstract class AbstractRubyTearOff extends AbstractTearOff { - protected AbstractRubyTearOff(MetaClass owner) { - super(owner, JRubyClassLoaderTearOff.class); - } - - /** - * Defines the file extension, like ".erb", that designates this kind of view type. - */ - @Override - protected abstract String getDefaultScriptExtension(); - - @Override - public Script parseScript(URL res) throws IOException { - return WebApp.getCurrent().getFacet(JRubyFacet.class).parseScript(res); - } - - /** - * Creates a {@link RequestDispatcher} that forwards to the jelly view, if available. - */ - public RequestDispatcher createDispatcher(Object it, String viewName) throws IOException { - Script script = findScript(viewName+getDefaultScriptExtension()); - if(script!=null) - return new JellyRequestDispatcher(it,script); - return null; - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/IJRubyContext.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/IJRubyContext.java deleted file mode 100644 index 192df67510..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/IJRubyContext.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.apache.commons.jelly.JellyContext; -import org.apache.commons.jelly.XMLOutput; - -/** - * @author Kohsuke Kawaguchi - */ -public interface IJRubyContext { - JellyContext getJellyContext(); - void setJellyContext(JellyContext context); - XMLOutput getOutput(); - void setOutput(XMLOutput output); -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyClassLoaderTearOff.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyClassLoaderTearOff.java deleted file mode 100644 index e61ea23f79..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyClassLoaderTearOff.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.kohsuke.stapler.MetaClassLoader; - -/** - * @author Kohsuke Kawaguchi - */ -public class JRubyClassLoaderTearOff { - private final MetaClassLoader owner; - - public JRubyClassLoaderTearOff(MetaClassLoader owner) { - this.owner = owner; - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyFacet.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyFacet.java deleted file mode 100644 index c6ba24fbd6..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyFacet.java +++ /dev/null @@ -1,228 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.apache.commons.jelly.JellyTagException; -import org.apache.commons.jelly.Script; -import org.jruby.RubyClass; -import org.jruby.RubyModule; -import org.jruby.RubyObject; -import org.jruby.embed.LocalContextScope; -import org.jruby.embed.ScriptingContainer; -import org.kohsuke.MetaInfServices; -import org.kohsuke.stapler.Dispatcher; -import org.kohsuke.stapler.Facet; -import org.kohsuke.stapler.MetaClass; -import org.kohsuke.stapler.RequestImpl; -import org.kohsuke.stapler.ResponseImpl; -import org.kohsuke.stapler.TearOffSupport; -import org.kohsuke.stapler.WebApp; -import org.kohsuke.stapler.jelly.JellyCompatibleFacet; -import org.kohsuke.stapler.jelly.JellyFacet; -import org.kohsuke.stapler.jelly.jruby.erb.ERbClassTearOff; -import org.kohsuke.stapler.lang.Klass; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.logging.Level; - -import static java.util.logging.Level.FINE; - -/** - * {@link Facet} that adds Ruby-based view technologies. - * - * @author Kohsuke Kawaguchi - * @author Hiroshi Nakamura - */ -@MetaInfServices(Facet.class) -public class JRubyFacet extends Facet implements JellyCompatibleFacet { - /*package*/ final List languages = new CopyOnWriteArrayList<>(); - - /** - * There are all kinds of downsides in doing this, but for the time being we just use one scripting container. - */ - private final ScriptingContainer container; - - private final RubyKlassNavigator navigator; - - /** - * {@link RubyTemplateContainer}s keyed by their {@linkplain RubyTemplateLanguage#getScriptExtension() extensions}. - * (since {@link #container} is a singleton per {@link JRubyFacet}, this is also just one map. - */ - private final Map templateContainers = new HashMap<>(); - - private final Collection> tearOffTypes = new CopyOnWriteArrayList<>(); - - public JRubyFacet() { - // TODO: is this too early? Shall we allow registrations later? - languages.addAll(Facet.discoverExtensions(RubyTemplateLanguage.class, - Thread.currentThread().getContextClassLoader(), getClass().getClassLoader())); - - container = new ScriptingContainer(LocalContextScope.SINGLETHREAD); // we don't want any funny multiplexing from ScriptingContainer. - container.runScriptlet("require 'org/kohsuke/stapler/jelly/jruby/JRubyJellyScriptImpl'"); - - navigator = new RubyKlassNavigator(container.getProvider().getRuntime(), getClass().getClassLoader()); - - for (RubyTemplateLanguage l : languages) { - templateContainers.put(l.getScriptExtension(),l.createContainer(container)); - tearOffTypes.add(l.getTearOffClass()); - } - } - - private RubyTemplateContainer selectTemplateContainer(String path) { - int idx = path.lastIndexOf('.'); - if (idx >= 0) { - RubyTemplateContainer t = templateContainers.get(path.substring(idx)); - if (t!=null) return t; - } - throw new IllegalArgumentException("Unrecognized file extension: "+path); - } - - public Script parseScript(URL template) throws IOException { - return selectTemplateContainer(template.getPath()).parseScript(template); - } - - @Override - public Klass getKlass(Object o) { - if (o instanceof RubyObject) - return makeKlass(((RubyObject) o).getMetaClass()); - return null; - } - - private Klass makeKlass(RubyModule o) { - return new Klass<>(o,navigator); - } - - public synchronized MetaClass getClassInfo(RubyClass r) { - return WebApp.getCurrent().getMetaClass(makeKlass(r)); - } - - private boolean isRuby(MetaClass mc) { - return mc.klass.clazz instanceof RubyModule; - } - - @Override - public void buildViewDispatchers(final MetaClass owner, List dispatchers) { - for (final Class t : getClassTearOffTypes()) { - dispatchers.add(new ScriptInvokingDispatcher() { - final AbstractRubyTearOff tearOff = owner.loadTearOff(t); - @Override - public boolean dispatch(RequestImpl req, ResponseImpl rsp, Object node) throws IOException, ServletException { - String next = req.tokens.peek(); - if(next==null) return false; - - // only match the end of the URL - if (req.tokens.countRemainingTokens()>1) return false; - // and avoid serving both "foo" and "foo/" as relative URL semantics are drastically different - if (req.getRequestURI().endsWith("/")) return false; - - if (!isBasename(next)) { - // potentially an attempt to make a folder traversal - return false; - } - - Script script = tearOff.findScript(next); - - if (script == null) { - // no script found - return false; - } - - return invokeScript(req, rsp, node, next, script); - } - }); - } - } - - @Override - public void buildFallbackDispatchers(MetaClass owner, List dispatchers) { - if (isRuby(owner)) { - dispatchers.add(new RackDispatcher()); - } - } - - @Override - public Collection> getClassTearOffTypes() { - return tearOffTypes; - } - - @Override - public Collection getScriptExtensions() { - List r = new ArrayList<>(); - for (RubyTemplateLanguage l : languages) - r.add(l.getScriptExtension()); - return r; - } - - - @Override - public RequestDispatcher createRequestDispatcher(RequestImpl request, Klass type, Object it, String viewName) throws IOException { - TearOffSupport mc = request.stapler.getWebApp().getMetaClass(type); - return mc.loadTearOff(ERbClassTearOff.class).createDispatcher(it,viewName); - } - - private ScriptDispatcher makeIndexDispatcher(MetaClass mc) throws IOException { - for (Class t : getClassTearOffTypes()) { - final AbstractRubyTearOff rt = mc.loadTearOff(t); - final Script script = rt.findScript("index"); - if(script!=null) - return new ScriptDispatcher(rt, script); - } - return null; - } - - @Override - public void buildIndexDispatchers(MetaClass mc, List dispatchers) { - try { - ScriptDispatcher d = makeIndexDispatcher(mc); - if (d!=null) - dispatchers.add(d); - } catch (IOException e) { - LOGGER.log(Level.WARNING, "Failed to parse Ruby index view for "+mc, e); - } - } - - @Override - public boolean handleIndexRequest(RequestImpl req, ResponseImpl rsp, Object node, MetaClass mc) throws IOException, ServletException { - ScriptDispatcher d = makeIndexDispatcher(mc); - return d!=null && d.dispatch(req,rsp,node); - } - - private static class ScriptDispatcher extends Dispatcher { - private final AbstractRubyTearOff rt; - private final Script script; - - public ScriptDispatcher(AbstractRubyTearOff rt, Script script) { - this.rt = rt; - this.script = script; - } - - @Override - public boolean dispatch(RequestImpl req, ResponseImpl rsp, Object node) throws IOException, ServletException { - try { - if (req.tokens.hasMore()) - return false; - - if(LOGGER.isLoggable(FINE)) - LOGGER.fine("Invoking index"+ rt.getDefaultScriptExtension()+" on " + node); - - WebApp.getCurrent().getFacet(JellyFacet.class).scriptInvoker.invokeScript(req, rsp, script, node); - return true; - } catch (JellyTagException e) { - throw new ServletException(e); - } - } - - @Override - public String toString() { - return "index"+ rt.getDefaultScriptExtension()+" for url=/"; - } - } -} - diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyJellyScript.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyJellyScript.java deleted file mode 100644 index 7197e1d376..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/JRubyJellyScript.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.apache.commons.jelly.JellyContext; -import org.apache.commons.jelly.JellyException; -import org.apache.commons.jelly.JellyTagException; -import org.apache.commons.jelly.Script; -import org.apache.commons.jelly.TagLibrary; -import org.apache.commons.jelly.XMLOutput; -import org.apache.commons.jelly.expression.ConstantExpression; -import org.apache.commons.jelly.impl.TagScript; -import org.jruby.Ruby; -import org.jruby.RubyProc; -import org.jruby.RubySymbol; -import org.jruby.runtime.builtin.IRubyObject; - -import java.util.Map; -import java.util.Map.Entry; - -/** - * Exposes ERb/Haml scripts as {@link Script}. - * - *

- * This abstract class defines the Java half of it, and it is further subtyped in Ruby for different languages. - * - * @author Kohsuke Kawaguchi - */ -public abstract class JRubyJellyScript implements Script { - - protected JRubyJellyScript() { - } - - @Override - public Script compile() throws JellyException { - return this; - } - - // this method is implemented in Ruby - @Override - public abstract void run(JellyContext context, XMLOutput output) throws JellyTagException; - - /** - * Invokes other Jelly tag libraries. - */ - public void invokeTaglib(final IJRubyContext rcon, JellyContext context, XMLOutput output, String uri, String localName, Map attributes, final RubyProc proc) throws JellyException { - TagScript tagScript = createTagScript(context, uri, localName); - - if (attributes!=null) { - for (Entry e : attributes.entrySet()) { - tagScript.addAttribute(e.getKey().asJavaString(), new ConstantExpression(e.getValue())); - } - } - - if (proc!=null) { - final Ruby runtime = ((IRubyObject)rcon).getRuntime(); - - tagScript.setTagBody(new Script() { - @Override - public Script compile() throws JellyException { - return this; - } - - @Override - public void run(JellyContext context, XMLOutput output) throws JellyTagException { - JellyContext oc = rcon.getJellyContext(); - XMLOutput oo = rcon.getOutput(); - try { - rcon.setJellyContext(context); - rcon.setOutput(output); - proc.getBlock().yield(runtime.getCurrentContext(),null); - } finally { - rcon.setJellyContext(oc); - rcon.setOutput(oo); - } - } - }); - } - tagScript.run(context, output); - } - - private TagScript createTagScript(JellyContext context, String uri, String name) throws JellyException { - TagLibrary lib = context.getTagLibrary(uri); - if (lib==null) - throw new JellyException("Undefined tag library namespace URI: "+uri); - TagScript tagScript = lib.createTagScript(name, null/*this parameter appears to be unused.*/); - if (tagScript!=null) return tagScript; - tagScript = lib.createTagScript(name.replace('_','-'), null); - if (tagScript!=null) return tagScript; - throw new JellyException(String.format("name '%s' not found for '%s'", name, uri)); - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RackDispatcher.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RackDispatcher.java deleted file mode 100644 index ee1189b0ac..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RackDispatcher.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.jruby.Ruby; -import org.jruby.RubyModule; -import org.jruby.RubyObject; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.rack.DefaultRackApplication; -import org.jruby.rack.servlet.*; -import org.jruby.runtime.builtin.IRubyObject; -import org.kohsuke.stapler.Dispatcher; -import org.kohsuke.stapler.RequestImpl; -import org.kohsuke.stapler.ResponseImpl; -import org.kohsuke.stapler.Stapler; - -import javax.servlet.ServletException; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -/** - * {@link Dispatcher} that looks for the Rack-compliant call method. - * - * @author Kohsuke Kawaguchi - */ -public class RackDispatcher extends Dispatcher { - @Override - public boolean dispatch(final RequestImpl req, ResponseImpl rsp, Object node) throws IOException, ServletException, IllegalAccessException, InvocationTargetException { - RubyObject x = (RubyObject) node; - Ruby runtime = x.getRuntime(); - - DynamicMethod m = x.getMetaClass().searchMethod("call"); - if (m==null) // does this instance respond to the 'call' method? - return false; - - // TODO: does the context need to live longer? - ServletRackContext rackContext = new DefaultServletRackContext(new ServletRackConfig(req.getServletContext())); - - // we don't want the Rack app to consider the portion of the URL that was already consumed - // to reach to the Rack app, so for PATH_INFO we use getRestOfPath(), not getPathInfo() - ServletRackEnvironment env = new ServletRackEnvironment(req, rsp, rackContext) { - @Override - public String getPathInfo() { - return req.getRestOfPath(); - } - }; - // servletHandler = Rack::Handler::Servlet.new(node) - runtime.getLoadService().require("rack/handler/servlet"); - IRubyObject servletHandler = ((RubyModule)runtime.getModule("Rack").getConstantAt("Handler")).getClass("Servlet").callMethod("new", x); - - DefaultRackApplication dra = new DefaultRackApplication(); - dra.setApplication(servletHandler); - dra.call(env) - .respond(new ServletRackResponseEnvironment(Stapler.getCurrentResponse())); - - return true; - } - - @Override - public String toString() { - return "call(env) to delegate to Rack-compatible Ruby objects"; - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyKlassNavigator.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyKlassNavigator.java deleted file mode 100644 index 9f8a9d5a5c..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyKlassNavigator.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.jruby.Ruby; -import org.jruby.RubyClass; -import org.jruby.RubyModule; -import org.jruby.RubyObject; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.kohsuke.stapler.ClassDescriptor; -import org.kohsuke.stapler.Function; -import org.kohsuke.stapler.MetaClassLoader; -import org.kohsuke.stapler.lang.FieldRef; -import org.kohsuke.stapler.lang.Klass; -import org.kohsuke.stapler.lang.KlassNavigator; -import org.kohsuke.stapler.lang.MethodRef; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; - -/** - * {@link KlassNavigator} implementation for JRuby. - * - * @author Kohsuke Kawaguchi - */ -public class RubyKlassNavigator extends KlassNavigator { - private final Ruby ruby; - /** - * ClassLoader to load resources from. - */ - private final ClassLoader classLoader; - - public RubyKlassNavigator(Ruby ruby, ClassLoader cl) { - this.ruby = ruby; - this.classLoader = cl; - } - - - @Override - public URL getResource(RubyModule clazz, String resourceName) { - String fullName; - if (resourceName.startsWith("/")) - fullName = resourceName.substring(1); - else - fullName = decamelize(clazz.getName().replace("::","/")+'/'+resourceName); - - if (MetaClassLoader.debugLoader!=null) { - URL res = MetaClassLoader.debugLoader.loader.getResource(fullName); - if (res!=null) return res; - } - return classLoader.getResource(fullName); - } - - @Override - public Iterable> getAncestors(RubyModule clazz) { - List> r = new ArrayList<>(); - for (RubyModule anc : (List)(List)clazz.getAncestorList()) { - r.add(wrap(anc)); - } - return r; - } - - @Override - public Klass getSuperClass(RubyModule clazz) { - // TODO: what happens when a Ruby class extends from Java class? - return wrap(clazz.getSuperClass()); - } - - @Override - public List getDeclaredMethods(RubyModule clazz) { - List r = new ArrayList<>(); - for (DynamicMethod m : clazz.getMethods().values()) { - // TODO: not sure if this is entirely correct - if (m.getImplementationClass()==clazz) - r.add(new RubyMethodRef(clazz,m)); - } - return r; - } - - @Override - public List getDeclaredFields(RubyModule clazz) { - // IIUC, Ruby doesn't have statically defined instance fields - return Collections.emptyList(); - } - - @Override - public List getFunctions(RubyModule clazz) { - // implemented as a fallback to Java through reified class, but maybe there's a better way to do this - return new ClassDescriptor(toJavaClass(clazz)).methods; - } - - @Override - public Class toJavaClass(RubyModule clazz) { - if (clazz instanceof RubyClass) { - RubyClass rc = (RubyClass) clazz; - Class c = rc.getReifiedClass(); - if (c!=null) return c; // is this right? - } - return RubyObject.class; - } - - public Klass wrap(RubyModule m) { - return m==null ? null : new Klass<>(m,this); - } - - /** - * Converts "FooBarZot" to "foo_bar_zot" - */ - static String decamelize(String s) { - return s.replaceAll("(\\p{javaLetterOrDigit})(\\p{javaUpperCase}\\p{javaLowerCase})","$1_$2") - .replaceAll("(\\p{javaLowerCase})(\\p{javaUpperCase})","$1_$2") - .toLowerCase(Locale.ENGLISH); - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyMethodRef.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyMethodRef.java deleted file mode 100644 index 6a0b678802..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyMethodRef.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.jruby.RubyModule; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.javasupport.Java; -import org.jruby.runtime.builtin.IRubyObject; -import org.kohsuke.stapler.lang.MethodRef; - -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; -import edu.umd.cs.findbugs.annotations.NonNull; - -/** - * @author Kohsuke Kawaguchi - */ -public class RubyMethodRef extends MethodRef { - @NonNull - private final RubyModule klass; - @NonNull - private final DynamicMethod method; - - - public RubyMethodRef(@NonNull RubyModule klass, @NonNull DynamicMethod method) { - this.klass = klass; - this.method = method; - } - - /** - * Retrieves the Ruby module (aka class), for which the method is declared. - * @return Ruby module, which stores the method reference - * @since 1.248 - */ - @NonNull - public RubyModule getKlass() { - return klass; - } - - /** - * Retrieves the referenced method. - * @return Referenced method - * @since 1.248 - */ - @NonNull - public DynamicMethod getMethod() { - return method; - } - - @Override - public String getName() { - return method.getName(); - } - - @Override - public T getAnnotation(Class type) { - // TODO: what's the equivalent in JRuby? - return null; - } - - @Override - public Object invoke(Object _this, Object... args) throws InvocationTargetException, IllegalAccessException { - IRubyObject[] argList = new IRubyObject[args.length]; - for (int i=0; i - * One often needs to do some preparation work in every {@link ScriptingContainer} that it uses, - * such as loading gem. Instance of this captures that context. - * - *

- * Right now, we only use one {@link ScriptingContainer}, so this isn't serving any useful purpose, - * but this is in anticipation of the future expansion to handle multiple {@link ScriptingContainer}s. - * - * @author Kohsuke Kawaguchi - */ -public class RubyTemplateContainer { - /** - * Subtype of {@link JRubyJellyScript} for this specific template language. - */ - private final RubyClass scriptClass; - - /** - * Where we came from. - */ - public final RubyTemplateLanguage language; - - /** - * This {@link RubyTemplateContainer} instance if scoped to this JRuby interpreter context. - */ - public final ScriptingContainer container; - - public RubyTemplateContainer(RubyClass scriptClass, RubyTemplateLanguage language, ScriptingContainer container) { - this.scriptClass = scriptClass; - this.language = language; - this.container = container; - } - - @SuppressFBWarnings(value = "URLCONNECTION_SSRF_FD", justification = "Not relevant in this situation.") - public Script parseScript(URL path) throws IOException { - try { - String template = IOUtils.toString(path.openStream(), StandardCharsets.UTF_8); - return (Script) container.callMethod(scriptClass, "new", template); - } catch (Exception e) { - throw new IOException("Failed to parse " + path, e); - } - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyTemplateLanguage.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyTemplateLanguage.java deleted file mode 100644 index 3e49bbe752..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/RubyTemplateLanguage.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.jruby.embed.ScriptingContainer; - -/** - * Ruby template language binding. - * - *

- * Implementations of this is discovered via service-loader mechanism. - * - * @author Kohsuke Kawaguchi - */ -public abstract class RubyTemplateLanguage { - /** - * Defines the file extension, like ".erb", that designates this kind of view type. - */ - protected abstract String getScriptExtension(); - - protected abstract Class getTearOffClass(); - - /** - * Called to set up this template language binding on the specified scripting container. - */ - protected abstract RubyTemplateContainer createContainer(ScriptingContainer container); -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/ScriptInvokingDispatcher.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/ScriptInvokingDispatcher.java deleted file mode 100644 index b0f160da2c..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/ScriptInvokingDispatcher.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby; - -import org.apache.commons.jelly.Script; -import org.kohsuke.stapler.Dispatcher; -import org.kohsuke.stapler.RequestImpl; -import org.kohsuke.stapler.ResponseImpl; -import org.kohsuke.stapler.WebApp; -import org.kohsuke.stapler.jelly.JellyFacet; - -import javax.servlet.ServletException; -import java.io.IOException; - -/** - * {@link Dispatcher} that invokes view script. - * - * @author Kohsuke Kawaguchi - */ -abstract class ScriptInvokingDispatcher extends Dispatcher { - protected boolean invokeScript(RequestImpl req, ResponseImpl rsp, Object node, String next, Script script) throws IOException, ServletException { - try { - if(script==null) return false; - - req.tokens.next(); - - if(traceable()) - trace(req,rsp,"Invoking "+next+" on "+node+" for "+req.tokens); - - WebApp.getCurrent().getFacet(JellyFacet.class).scriptInvoker.invokeScript(req, rsp, script, node); - - return true; - } catch (RuntimeException | IOException e) { - throw e; - } catch (Exception e) { - throw new ServletException(e); - } - } - - @Override - public String toString() { - return "TOKEN for url=/TOKEN/..."; - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/erb/ERbClassTearOff.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/erb/ERbClassTearOff.java deleted file mode 100644 index 3949d680e0..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/erb/ERbClassTearOff.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby.erb; - -import org.kohsuke.stapler.MetaClass; -import org.kohsuke.stapler.jelly.jruby.AbstractRubyTearOff; - -/** - * Tear off that manages Ruby ERB views of Java objects (and not ruby objects.) - * - * @author Kohsuke Kawaguchi - */ -public class ERbClassTearOff extends AbstractRubyTearOff { - public ERbClassTearOff(MetaClass owner) { - super(owner); - } - - @Override - protected String getDefaultScriptExtension() { - return ".erb"; - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/erb/ERbLanguage.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/erb/ERbLanguage.java deleted file mode 100644 index e509380f2d..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/erb/ERbLanguage.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby.erb; - -import org.jruby.RubyClass; -import org.jruby.embed.ScriptingContainer; -import org.kohsuke.MetaInfServices; -import org.kohsuke.stapler.jelly.jruby.RubyTemplateContainer; -import org.kohsuke.stapler.jelly.jruby.RubyTemplateLanguage; - -/** - * @author Kohsuke Kawaguchi - */ -@MetaInfServices -public class ERbLanguage extends RubyTemplateLanguage { - @Override - protected String getScriptExtension() { - return ".erb"; - } - - @Override - protected Class getTearOffClass() { - return ERbClassTearOff.class; - } - - @Override - protected RubyTemplateContainer createContainer(ScriptingContainer jruby) { - return new RubyTemplateContainer( - (RubyClass)jruby.runScriptlet( - "require 'org/kohsuke/stapler/jelly/jruby/erb/JRubyJellyERbScript'\n"+ - "JRubyJellyScriptImpl::JRubyJellyERbScript"), - this, jruby); - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/haml/HamlClassTearOff.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/haml/HamlClassTearOff.java deleted file mode 100644 index b0f5fb2fd7..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/haml/HamlClassTearOff.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby.haml; - -import org.kohsuke.stapler.MetaClass; -import org.kohsuke.stapler.jelly.jruby.AbstractRubyTearOff; - -/** - * - * @author Kohsuke Kawaguchi - */ -public class HamlClassTearOff extends AbstractRubyTearOff { - public HamlClassTearOff(MetaClass owner) { - super(owner); - } - - @Override - protected String getDefaultScriptExtension() { - return ".haml"; - } -} diff --git a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/haml/HamlLanguage.java b/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/haml/HamlLanguage.java deleted file mode 100644 index 867912bb18..0000000000 --- a/jruby/src/main/java/org/kohsuke/stapler/jelly/jruby/haml/HamlLanguage.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.kohsuke.stapler.jelly.jruby.haml; - -import org.jruby.RubyClass; -import org.jruby.embed.ScriptingContainer; -import org.kohsuke.MetaInfServices; -import org.kohsuke.stapler.jelly.jruby.RubyTemplateContainer; -import org.kohsuke.stapler.jelly.jruby.RubyTemplateLanguage; - -/** - * @author Hiroshi Nakamura - */ -@MetaInfServices -public class HamlLanguage extends RubyTemplateLanguage { - @Override - protected String getScriptExtension() { - return ".haml"; - } - - @Override - protected Class getTearOffClass() { - return HamlClassTearOff.class; - } - - @Override - protected RubyTemplateContainer createContainer(ScriptingContainer jruby) { - jruby.put("gem_path", getClass().getResource("/gem").getPath()); - - return new RubyTemplateContainer( - (RubyClass)jruby.runScriptlet("ENV['GEM_PATH'] = gem_path\n" + - "require 'rubygems'\n" + - "require 'org/kohsuke/stapler/jelly/jruby/JRubyJellyScriptImpl'\n"+ - "require 'org/kohsuke/stapler/jelly/jruby/haml/JRubyJellyHamlScript'\n"+ - "JRubyJellyScriptImpl::JRubyJellyHamlScript" - ), - this, jruby); - } -} diff --git a/jruby/src/main/resources/gem/bin/haml b/jruby/src/main/resources/gem/bin/haml deleted file mode 100755 index 6b192fc768..0000000000 --- a/jruby/src/main/resources/gem/bin/haml +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/local/bin/ruby -# -# This file was generated by RubyGems. -# -# The application 'haml' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'rubygems' - -version = ">= 0" - -if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then - version = $1 - ARGV.shift -end - -gem 'haml', version -load Gem.bin_path('haml', 'haml', version) diff --git a/jruby/src/main/resources/gem/bin/html2haml b/jruby/src/main/resources/gem/bin/html2haml deleted file mode 100755 index d82349be9a..0000000000 --- a/jruby/src/main/resources/gem/bin/html2haml +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/local/bin/ruby -# -# This file was generated by RubyGems. -# -# The application 'haml' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'rubygems' - -version = ">= 0" - -if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then - version = $1 - ARGV.shift -end - -gem 'haml', version -load Gem.bin_path('haml', 'html2haml', version) diff --git a/jruby/src/main/resources/gem/cache/haml-3.1.1.gem b/jruby/src/main/resources/gem/cache/haml-3.1.1.gem deleted file mode 100644 index dae36b258d..0000000000 Binary files a/jruby/src/main/resources/gem/cache/haml-3.1.1.gem and /dev/null differ diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/.yardopts b/jruby/src/main/resources/gem/gems/haml-3.1.1/.yardopts deleted file mode 100644 index c1c79a1991..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/.yardopts +++ /dev/null @@ -1,11 +0,0 @@ ---readme README.md ---markup markdown ---markup-provider maruku ---default-return "" ---title "Haml Documentation" ---query 'object.type != :classvariable' ---query 'object.type != :constant || @api && @api.text == "public"' ---hide-void-return ---protected ---no-private ---no-highlight diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/CONTRIBUTING b/jruby/src/main/resources/gem/gems/haml-3.1.1/CONTRIBUTING deleted file mode 100644 index f611387794..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/CONTRIBUTING +++ /dev/null @@ -1,3 +0,0 @@ -Contributions are welcomed. Please see the following sites for guidelines: - - http://haml-lang.com/development.html#contributing diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/MIT-LICENSE b/jruby/src/main/resources/gem/gems/haml-3.1.1/MIT-LICENSE deleted file mode 100644 index 89c3814d26..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2006-2009 Hampton Catlin and Nathan Weizenbaum - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/README.md b/jruby/src/main/resources/gem/gems/haml-3.1.1/README.md deleted file mode 100644 index df3d4d1f52..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/README.md +++ /dev/null @@ -1,133 +0,0 @@ -# Haml - -Haml is a templating engine for HTML. -It's are designed to make it both easier and more pleasant -to write HTML documents, -by eliminating redundancy, -reflecting the underlying structure that the document represents, -and providing elegant, easily understandable, and powerful syntax. - -## Using - -Haml can be used from the command line -or as part of a Ruby web framework. -The first step is to install the gem: - - gem install haml - -After you convert some HTML to Haml, you can run - - haml document.haml - -to compile them. -For more information on these commands, check out - - haml --help - -To install Haml in Rails 2, -just add `config.gem "haml"` to `config/environment.rb`. -In Rails 3, add `gem "haml"` to your Gemfile instead. -and both Haml and Sass will be installed. -Views with the `.html.haml` extension will automatically use Haml. - -To use Haml programatically, -check out the [YARD documentation](http://haml-lang.com/docs/yardoc/). - -## Formatting - -The most basic element of Haml -is a shorthand for creating HTML: - - %tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents - -No end-tag is needed; Haml handles that automatically. -If you prefer HTML-style attributes, you can also use: - - %tagname(attr1='value1' attr2='value2') Contents - -Adding `class` and `id` attributes is even easier. -Haml uses the same syntax as the CSS that styles the document: - - %tagname#id.class - -In fact, when you're using the `

` tag, -it becomes _even easier_. -Because `
` is such a common element, -a tag without a name defaults to a div. So - - #foo Hello! - -becomes - -
Hello!
- -Haml uses indentation -to bring the individual elements to represent the HTML structure. -A tag's children are indented beneath than the parent tag. -Again, a closing tag is automatically added. -For example: - - %ul - %li Salt - %li Pepper - -becomes: - -
    -
  • Salt
  • -
  • Pepper
  • -
- -You can also put plain text as a child of an element: - - %p - Hello, - World! - -It's also possible to embed Ruby code into Haml documents. -An equals sign, `=`, will output the result of the code. -A hyphen, `-`, will run the code but not output the result. -You can even use control statements -like `if` and `while`: - - %p - Date/Time: - - now = DateTime.now - %strong= now - - if now > DateTime.parse("December 31, 2006") - = "Happy new " + "year!" - -Haml provides far more tools than those presented here. -Check out the [reference documentation](http://beta.haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html) -for full details. - -### Indentation - -Haml's indentation can be made up of one or more tabs or spaces. -However, indentation must be consistent within a given document. -Hard tabs and spaces can't be mixed, -and the same number of tabs or spaces must be used throughout. - -## Authors - -Haml was created by [Hampton Catlin](http://hamptoncatlin.com) -(hcatlin) and he is the author of the original implementation. However, Hampton -doesn't even know his way around the code anymore and now occasionally consults -on the language issues. Hampton lives in Jacksonville, Florida and is the lead -mobile developer for Wikimedia. - -[Nathan Weizenbaum](http://nex-3.com) is the primary developer and architect of -the "modern" Ruby implementation of Haml. His hard work has kept the project -alive by endlessly answering forum posts, fixing bugs, refactoring, finding -speed improvements, writing documentation, implementing new features, and -getting Hampton coffee (a fitting task for a boy-genius). Nathan lives in -Seattle, Washington and while not being a student at the University of -Washington or working at an internship, he consults for Unspace Interactive. - -If you use this software, you must pay Hampton a compliment. And -buy Nathan some jelly beans. Maybe pet a kitten. Yeah. Pet that kitty. - -Some of the work on Haml was supported by Unspace Interactive. - -Beyond that, the implementation is licensed under the MIT License. -Okay, fine, I guess that means compliments aren't __required__. diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/REVISION b/jruby/src/main/resources/gem/gems/haml-3.1.1/REVISION deleted file mode 100644 index 54798d678b..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/REVISION +++ /dev/null @@ -1 +0,0 @@ -(release) diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/Rakefile b/jruby/src/main/resources/gem/gems/haml-3.1.1/Rakefile deleted file mode 100644 index 889435d731..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/Rakefile +++ /dev/null @@ -1,394 +0,0 @@ -# ----- Utility Functions ----- - -def scope(path) - File.join(File.dirname(__FILE__), path) -end - -# ----- Benchmarking ----- - -desc < :"test:rails_compatibility" -else - task :default => :test -end - -require 'rake/testtask' - -Rake::TestTask.new do |t| - t.libs << 'lib' - test_files = FileList[scope('test/**/*_test.rb')] - test_files.exclude(scope('test/rails/*')) - test_files.exclude(scope('test/plugins/*')) - test_files.exclude(scope('test/haml/spec/*')) - t.test_files = test_files - t.verbose = true -end -Rake::Task[:test].send(:add_comment, < [:revision_file, :submodules, :permissions] do - version = get_version - File.open(scope('VERSION'), 'w') {|f| f.puts(version)} - load scope('haml.gemspec') - Gem::Builder.new(HAML_GEMSPEC).build - sh %{git checkout VERSION} - - pkg = "#{HAML_GEMSPEC.name}-#{HAML_GEMSPEC.version}" - mkdir_p "pkg" - verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"} - - sh %{rm -f pkg/#{pkg}.tar.gz} - verbose(false) {HAML_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}} - sh %{gzip pkg/#{pkg}.tar} -end - -task :permissions do - sh %{chmod -R a+rx bin} - sh %{chmod -R a+r .} - require 'shellwords' - Dir.glob('test/**/*_test.rb') do |file| - next if file =~ %r{^test/haml/spec/} - sh %{chmod a+rx #{file}} - end -end - -task :revision_file do - require 'lib/haml' - - release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION')) - if Haml.version[:rev] && !release - File.open(scope('REVISION'), 'w') { |f| f.puts Haml.version[:rev] } - elsif release - File.open(scope('REVISION'), 'w') { |f| f.puts "(release)" } - else - File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" } - end -end - -# We also need to get rid of this file after packaging. -at_exit { File.delete(scope('REVISION')) rescue nil } - -desc "Install Haml as a gem. Use SUDO=1 to install with sudo." -task :install => [:package] do - gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem' - sh %{#{'sudo ' if ENV["SUDO"]}#{gem} install --no-ri pkg/haml-#{get_version}} -end - -desc "Release a new Haml package to Rubyforge." -task :release => [:check_release, :package] do - name = File.read(scope("VERSION_NAME")).strip - version = File.read(scope("VERSION")).strip - sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem} - sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz} - sh %{gem push pkg/haml-#{version}.gem} -end - - -# Ensures that the VERSION file has been updated for a new release. -task :check_release do - version = File.read(scope("VERSION")).strip - raise "There have been changes since current version (#{version})" if changed_since?(version) - raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read(scope("VERSION_NAME")) == "Bleeding Edge" -end - -# Reads a password from the command line. -# -# @param name [String] The prompt to use to read the password -def read_password(prompt) - require 'readline' - system "stty -echo" - Readline.readline("#{prompt}: ").strip -ensure - system "stty echo" - puts -end - -# Returns whether or not the repository, or specific files, -# has/have changed since a given revision. -# -# @param rev [String] The revision to check against -# @param files [Array] The files to check. -# If this is empty, checks the entire repository -def changed_since?(rev, *files) - IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {} - return !$?.success? -end - -task :submodules do - if File.exist?(File.dirname(__FILE__) + "/.git") - sh %{git submodule sync} - sh %{git submodule update --init --recursive} - end -end - -task :release_edge do - ensure_git_cleanup do - puts "#{'=' * 50} Running rake release_edge" - - sh %{git checkout master} - sh %{git reset --hard origin/master} - sh %{rake package} - version = get_version - sh %{rubyforge add_release haml haml "Bleeding Edge (v#{version})" pkg/haml-#{version}.gem} - sh %{gem push pkg/haml-#{version}.gem} - end -end - -# Get the version string. If this is being installed from Git, -# this includes the proper prerelease version. -def get_version - written_version = File.read(scope('VERSION').strip) - return written_version unless File.exist?(scope('.git')) - - # Get the current master branch version - version = written_version.split('.') - version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n} - return written_version unless version.size == 5 && version[3] == "alpha" # prerelease - - return written_version if (commit_count = `git log --pretty=oneline --first-parent stable.. | wc -l`).empty? - version[4] = commit_count.strip - version.join('.') -end - -task :watch_for_update do - sh %{ruby extra/update_watch.rb} -end - -# ----- Documentation ----- - -task :rdoc do - puts '=' * 100, < :yard - task :redoc => :yard -rescue LoadError - desc "Generate Documentation" - task :doc => :rdoc - task :yard => :rdoc -end - -task :pages do - puts "#{'=' * 50} Running rake pages" - ensure_git_cleanup do - sh %{git checkout haml-pages} - sh %{git reset --hard origin/haml-pages} - - Dir.chdir("/var/www/haml-pages") do - sh %{git fetch origin} - - sh %{git checkout stable} - sh %{git reset --hard origin/stable} - - sh %{git checkout haml-pages} - sh %{git reset --hard origin/haml-pages} - sh %{rake build --trace} - sh %{mkdir -p tmp} - sh %{touch tmp/restart.txt} - end - end -end - -# ----- Coverage ----- - -begin - require 'rcov/rcovtask' - - Rcov::RcovTask.new do |t| - t.test_files = FileList[scope('test/**/*_test.rb')] - t.rcov_opts << '-x' << '"^\/"' - if ENV['NON_NATIVE'] - t.rcov_opts << "--no-rcovrt" - end - t.verbose = true - end -rescue LoadError; end - -# ----- Profiling ----- - -begin - require 'ruby-prof' - - desc < e - IO.popen("sendmail nex342@gmail.com", "w") do |sm| - sm << "From: nex3@nex-3.com\n" << - "To: nex342@gmail.com\n" << - "Subject: Exception when running rake #{Rake.application.top_level_tasks.join(', ')}\n" << - e.message << "\n\n" << - e.backtrace.join("\n") - end -ensure - raise e if e -end - -def ensure_git_cleanup - email_on_error {yield} -ensure - sh %{git reset --hard HEAD} - sh %{git clean -xdf} - sh %{git checkout master} -end - -task :handle_update do - email_on_error do - unless ENV["REF"] =~ %r{^refs/heads/(master|stable|haml-pages)$} - puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}" - next - end - branch = $1 - - puts - puts - puts '=' * 150 - puts "Running rake handle_update REF=#{ENV["REF"].inspect}" - - sh %{git fetch origin} - sh %{git checkout stable} - sh %{git reset --hard origin/stable} - sh %{git checkout master} - sh %{git reset --hard origin/master} - - case branch - when "master" - sh %{rake release_edge --trace} - when "stable", "haml-pages" - sh %{rake pages --trace} - end - - puts 'Done running handle_update' - puts '=' * 150 - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/VERSION b/jruby/src/main/resources/gem/gems/haml-3.1.1/VERSION deleted file mode 100644 index 94ff29cc4d..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.1.1 diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/VERSION_NAME b/jruby/src/main/resources/gem/gems/haml-3.1.1/VERSION_NAME deleted file mode 100644 index 8fe711e933..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/VERSION_NAME +++ /dev/null @@ -1 +0,0 @@ -Separated Sally diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/bin/haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/bin/haml deleted file mode 100755 index 1a24e4e42a..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/bin/haml +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env ruby -# The command line Haml parser. - -$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib' -require 'haml' -require 'haml/exec' - -opts = Haml::Exec::Haml.new(ARGV) -opts.parse! diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/bin/html2haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/bin/html2haml deleted file mode 100755 index a85e95a3a7..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/bin/html2haml +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../lib/haml' -require 'haml/exec' - -opts = Haml::Exec::HTML2Haml.new(ARGV) -opts.parse! diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/extra/update_watch.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/extra/update_watch.rb deleted file mode 100644 index 0d29c6081d..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/extra/update_watch.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'rubygems' -require 'sinatra' -require 'json' -set :port, 3123 -set :environment, :production -enable :lock -Dir.chdir(File.dirname(__FILE__) + "/..") - -post "/" do - puts "Recieved payload!" - puts "Rev: #{`git name-rev HEAD`.strip}" - system %{rake handle_update --trace REF=#{JSON.parse(params["payload"])["ref"].inspect}} -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/init.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/init.rb deleted file mode 100644 index f8b3dab1a8..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/init.rb +++ /dev/null @@ -1,18 +0,0 @@ -begin - require File.join(File.dirname(__FILE__), 'lib', 'haml') # From here -rescue LoadError - begin - require 'haml' # From gem - rescue LoadError => e - # gems:install may be run to install Haml with the skeleton plugin - # but not the gem itself installed. - # Don't die if this is the case. - raise e unless defined?(Rake) && - (Rake.application.top_level_tasks.include?('gems') || - Rake.application.top_level_tasks.include?('gems:install')) - end -end - -# Load Haml. -# Haml may be undefined if we're running gems:install. -Haml.init_rails(binding) if defined?(Haml) diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml.rb deleted file mode 100644 index 562443073d..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml.rb +++ /dev/null @@ -1,47 +0,0 @@ -dir = File.dirname(__FILE__) -$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir) - -require 'haml/version' - -# The module that contains everything Haml-related: -# -# * {Haml::Engine} is the class used to render Haml within Ruby code. -# * {Haml::Helpers} contains Ruby helpers available within Haml templates. -# * {Haml::Template} interfaces with web frameworks (Rails in particular). -# * {Haml::Error} is raised when Haml encounters an error. -# * {Haml::HTML} handles conversion of HTML to Haml. -# -# Also see the {file:HAML_REFERENCE.md full Haml reference}. -module Haml - # Initializes Haml for Rails. - # - # This method is called by `init.rb`, - # which is run by Rails on startup. - # We use it rather than putting stuff straight into `init.rb` - # so we can change the initialization behavior - # without modifying the file itself. - # - # @param binding [Binding] The context of the `init.rb` file. - # This isn't actually used; - # it's just passed in in case it needs to be used in the future - def self.init_rails(binding) - # 2.2 <= Rails < 3 - if defined?(Rails) && Rails.respond_to?(:configuration) && - Rails.configuration.respond_to?(:after_initialize) && - !Haml::Util.ap_geq_3? - Rails.configuration.after_initialize do - next if defined?(Sass) - autoload(:Sass, 'sass/rails2_shim') - # resolve autoload if it looks like they're using Sass without options - Sass if File.exist?(File.join(RAILS_ROOT, 'public/stylesheets/sass')) - end - end - - # No &method here for Rails 2.1 compatibility - %w[haml/template].each {|f| require f} - end -end - -require 'haml/util' -require 'haml/engine' -require 'haml/railtie' diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/buffer.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/buffer.rb deleted file mode 100644 index 67d189e750..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/buffer.rb +++ /dev/null @@ -1,297 +0,0 @@ -module Haml - # This class is used only internally. It holds the buffer of HTML that - # is eventually output as the resulting document. - # It's called from within the precompiled code, - # and helps reduce the amount of processing done within `instance_eval`ed code. - class Buffer - include Haml::Helpers - include Haml::Util - - # The string that holds the compiled HTML. This is aliased as - # `_erbout` for compatibility with ERB-specific code. - # - # @return [String] - attr_accessor :buffer - - # The options hash passed in from {Haml::Engine}. - # - # @return [{String => Object}] - # @see Haml::Engine#options_for_buffer - attr_accessor :options - - # The {Buffer} for the enclosing Haml document. - # This is set for partials and similar sorts of nested templates. - # It's `nil` at the top level (see \{#toplevel?}). - # - # @return [Buffer] - attr_accessor :upper - - # nil if there's no capture_haml block running, - # and the position at which it's beginning the capture if there is one. - # - # @return [Fixnum, nil] - attr_accessor :capture_position - - # @return [Boolean] - # @see #active? - attr_writer :active - - # @return [Boolean] Whether or not the format is XHTML - def xhtml? - not html? - end - - # @return [Boolean] Whether or not the format is any flavor of HTML - def html? - html4? or html5? - end - - # @return [Boolean] Whether or not the format is HTML4 - def html4? - @options[:format] == :html4 - end - - # @return [Boolean] Whether or not the format is HTML5. - def html5? - @options[:format] == :html5 - end - - # @return [Boolean] Whether or not this buffer is a top-level template, - # as opposed to a nested partial - def toplevel? - upper.nil? - end - - # Whether or not this buffer is currently being used to render a Haml template. - # Returns `false` if a subtemplate is being rendered, - # even if it's a subtemplate of this buffer's template. - # - # @return [Boolean] - def active? - @active - end - - # @return [Fixnum] The current indentation level of the document - def tabulation - @real_tabs + @tabulation - end - - # Sets the current tabulation of the document. - # - # @param val [Fixnum] The new tabulation - def tabulation=(val) - val = val - @real_tabs - @tabulation = val > -1 ? val : 0 - end - - # @param upper [Buffer] The parent buffer - # @param options [{Symbol => Object}] An options hash. - # See {Haml::Engine#options\_for\_buffer} - def initialize(upper = nil, options = {}) - @active = true - @upper = upper - @options = options - @buffer = ruby1_8? ? "" : "".encode(Encoding.find(options[:encoding])) - @tabulation = 0 - - # The number of tabs that Engine thinks we should have - # @real_tabs + @tabulation is the number of tabs actually output - @real_tabs = 0 - end - - # Appends text to the buffer, properly tabulated. - # Also modifies the document's indentation. - # - # @param text [String] The text to append - # @param tab_change [Fixnum] The number of tabs by which to increase - # or decrease the document's indentation - # @param dont_tab_up [Boolean] If true, don't indent the first line of `text` - def push_text(text, tab_change, dont_tab_up) - if @tabulation > 0 - # Have to push every line in by the extra user set tabulation. - # Don't push lines with just whitespace, though, - # because that screws up precompiled indentation. - text.gsub!(/^(?!\s+$)/m, tabs) - text.sub!(tabs, '') if dont_tab_up - end - - @buffer << text - @real_tabs += tab_change - end - - # Modifies the indentation of the document. - # - # @param tab_change [Fixnum] The number of tabs by which to increase - # or decrease the document's indentation - def adjust_tabs(tab_change) - @real_tabs += tab_change - end - - Haml::Util.def_static_method(self, :format_script, [:result], - :preserve_script, :in_tag, :preserve_tag, :escape_html, - :nuke_inner_whitespace, :interpolated, :ugly, < - <% unless ugly %> - # If we're interpolated, - # then the custom tabulation is handled in #push_text. - # The easiest way to avoid it here is to reset @tabulation. - <% if interpolated %> - old_tabulation = @tabulation - @tabulation = 0 - <% end %> - - tabulation = @real_tabs - result = <%= result_name %>.<% if nuke_inner_whitespace %>strip<% else %>rstrip<% end %> - <% else %> - result = <%= result_name %><% if nuke_inner_whitespace %>.strip<% end %> - <% end %> - - <% if preserve_tag %> - result = Haml::Helpers.preserve(result) - <% elsif preserve_script %> - result = Haml::Helpers.find_and_preserve(result, options[:preserve]) - <% end %> - - <% if ugly %> - return result - <% else %> - - has_newline = result.include?("\\n") - <% if in_tag && !nuke_inner_whitespace %> - <% unless preserve_tag %> if !has_newline <% end %> - @real_tabs -= 1 - <% if interpolated %> @tabulation = old_tabulation <% end %> - return result - <% unless preserve_tag %> end <% end %> - <% end %> - - # Precompiled tabulation may be wrong - <% if !interpolated && !in_tag %> - result = tabs + result if @tabulation > 0 - <% end %> - - if has_newline - result = result.gsub "\\n", "\\n" + tabs(tabulation) - - # Add tabulation if it wasn't precompiled - <% if in_tag && !nuke_inner_whitespace %> result = tabs(tabulation) + result <% end %> - end - - <% if in_tag && !nuke_inner_whitespace %> - result = "\\n\#{result}\\n\#{tabs(tabulation-1)}" - @real_tabs -= 1 - <% end %> - <% if interpolated %> @tabulation = old_tabulation <% end %> - result - <% end %> -RUBY - - def attributes(class_id, obj_ref, *attributes_hashes) - attributes = class_id - attributes_hashes.each do |old| - self.class.merge_attrs(attributes, to_hash(old.map {|k, v| [k.to_s, v]})) - end - self.class.merge_attrs(attributes, parse_object_ref(obj_ref)) if obj_ref - Compiler.build_attributes( - html?, @options[:attr_wrapper], @options[:escape_attrs], attributes) - end - - # Remove the whitespace from the right side of the buffer string. - # Doesn't do anything if we're at the beginning of a capture_haml block. - def rstrip! - if capture_position.nil? - buffer.rstrip! - return - end - - buffer << buffer.slice!(capture_position..-1).rstrip - end - - # Merges two attribute hashes. - # This is the same as `to.merge!(from)`, - # except that it merges id, class, and data attributes. - # - # ids are concatenated with `"_"`, - # and classes are concatenated with `" "`. - # data hashes are simply merged. - # - # Destructively modifies both `to` and `from`. - # - # @param to [{String => String}] The attribute hash to merge into - # @param from [{String => #to_s}] The attribute hash to merge from - # @return [{String => String}] `to`, after being merged - def self.merge_attrs(to, from) - from['id'] = Compiler.filter_and_join(from['id'], '_') if from['id'] - if to['id'] && from['id'] - to['id'] << '_' << from.delete('id').to_s - elsif to['id'] || from['id'] - from['id'] ||= to['id'] - end - - from['class'] = Compiler.filter_and_join(from['class'], ' ') if from['class'] - if to['class'] && from['class'] - # Make sure we don't duplicate class names - from['class'] = (from['class'].to_s.split(' ') | to['class'].split(' ')).sort.join(' ') - elsif to['class'] || from['class'] - from['class'] ||= to['class'] - end - - from_data = from['data'].is_a?(Hash) - to_data = to['data'].is_a?(Hash) - if from_data && to_data - to['data'] = to['data'].merge(from['data']) - elsif to_data - to = Haml::Util.map_keys(to.delete('data')) {|name| "data-#{name}"}.merge(to) - elsif from_data - from = Haml::Util.map_keys(from.delete('data')) {|name| "data-#{name}"}.merge(from) - end - - to.merge!(from) - end - - private - - @@tab_cache = {} - # Gets `count` tabs. Mostly for internal use. - def tabs(count = 0) - tabs = [count + @tabulation, 0].max - @@tab_cache[tabs] ||= ' ' * tabs - end - - # Takes an array of objects and uses the class and id of the first - # one to create an attributes hash. - # The second object, if present, is used as a prefix, - # just like you can do with `dom_id()` and `dom_class()` in Rails - def parse_object_ref(ref) - prefix = ref[1] - ref = ref[0] - # Let's make sure the value isn't nil. If it is, return the default Hash. - return {} if ref.nil? - class_name = - if ref.respond_to?(:haml_object_ref) - ref.haml_object_ref - else - underscore(ref.class) - end - id = "#{class_name}_#{ref.id || 'new'}" - if prefix - class_name = "#{ prefix }_#{ class_name}" - id = "#{ prefix }_#{ id }" - end - - {'id' => id, 'class' => class_name} - end - - # Changes a word from camel case to underscores. - # Based on the method of the same name in Rails' Inflector, - # but copied here so it'll run properly without Rails. - def underscore(camel_cased_word) - camel_cased_word.to_s.gsub(/::/, '_'). - gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2'). - tr("-", "_"). - downcase - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/compiler.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/compiler.rb deleted file mode 100644 index c742a40bfc..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/compiler.rb +++ /dev/null @@ -1,452 +0,0 @@ -require 'cgi' - -module Haml - module Compiler - include Haml::Util - - private - - # Returns the precompiled string with the preamble and postamble - def precompiled_with_ambles(local_names) - preamble = < @node.value[:preserve], - :escape_html => @node.value[:escape_html], &block) - end - - def compile_silent_script - return if @options[:suppress_eval] - push_silent(@node.value[:text]) - keyword = @node.value[:keyword] - ruby_block = block_given? && !keyword - - if block_given? - # Store these values because for conditional statements, - # we want to restore them for each branch - @node.value[:dont_indent_next_line] = @dont_indent_next_line - @node.value[:dont_tab_up_next_text] = @dont_tab_up_next_text - yield - push_silent("end", :can_suppress) unless @node.value[:dont_push_end] - elsif keyword == "end" - if @node.parent.children.last.equal?(@node) - # Since this "end" is ending the block, - # we don't need to generate an additional one - @node.parent.value[:dont_push_end] = true - end - # Don't restore dont_* for end because it isn't a conditional branch. - elsif Parser::MID_BLOCK_KEYWORDS.include?(keyword) - # Restore dont_* for this conditional branch - @dont_indent_next_line = @node.parent.value[:dont_indent_next_line] - @dont_tab_up_next_text = @node.parent.value[:dont_tab_up_next_text] - end - end - - def compile_haml_comment; end - - def compile_tag - t = @node.value - - # Get rid of whitespace outside of the tag if we need to - rstrip_buffer! if t[:nuke_outer_whitespace] - - dont_indent_next_line = - (t[:nuke_outer_whitespace] && !block_given?) || - (t[:nuke_inner_whitespace] && block_given?) - - if @options[:suppress_eval] - object_ref = "nil" - parse = false - value = t[:parse] ? nil : t[:value] - attributes_hashes = {} - preserve_script = false - else - object_ref = t[:object_ref] - parse = t[:parse] - value = t[:value] - attributes_hashes = t[:attributes_hashes] - preserve_script = t[:preserve_script] - end - - # Check if we can render the tag directly to text and not process it in the buffer - if object_ref == "nil" && attributes_hashes.empty? && !preserve_script - tag_closed = !block_given? && !t[:self_closing] && !parse - - open_tag = prerender_tag(t[:name], t[:self_closing], t[:attributes]) - if tag_closed - open_tag << "#{value}" - open_tag << "\n" unless t[:nuke_outer_whitespace] - elsif !(parse || t[:nuke_inner_whitespace] || - (t[:self_closing] && t[:nuke_outer_whitespace])) - open_tag << "\n" - end - - push_merged_text(open_tag, - tag_closed || t[:self_closing] || t[:nuke_inner_whitespace] ? 0 : 1, - !t[:nuke_outer_whitespace]) - - @dont_indent_next_line = dont_indent_next_line - return if tag_closed - else - if attributes_hashes.empty? - attributes_hashes = '' - elsif attributes_hashes.size == 1 - attributes_hashes = ", #{attributes_hashes.first}" - else - attributes_hashes = ", (#{attributes_hashes.join(").merge(")})" - end - - push_merged_text "<#{t[:name]}", 0, !t[:nuke_outer_whitespace] - push_generated_script( - "_hamlout.attributes(#{inspect_obj(t[:attributes])}, #{object_ref}#{attributes_hashes})") - concat_merged_text( - if t[:self_closing] && xhtml? - " />" + (t[:nuke_outer_whitespace] ? "" : "\n") - else - ">" + ((if t[:self_closing] && html? - t[:nuke_outer_whitespace] - else - !block_given? || t[:preserve_tag] || t[:nuke_inner_whitespace] - end) ? "" : "\n") - end) - - if value && !parse - concat_merged_text("#{value}#{t[:nuke_outer_whitespace] ? "" : "\n"}") - else - @to_merge << [:text, '', 1] unless t[:nuke_inner_whitespace] - end - - @dont_indent_next_line = dont_indent_next_line - end - - return if t[:self_closing] - - if value.nil? - @output_tabs += 1 unless t[:nuke_inner_whitespace] - yield if block_given? - @output_tabs -= 1 unless t[:nuke_inner_whitespace] - rstrip_buffer! if t[:nuke_inner_whitespace] - push_merged_text("" + (t[:nuke_outer_whitespace] ? "" : "\n"), - t[:nuke_inner_whitespace] ? 0 : -1, !t[:nuke_inner_whitespace]) - @dont_indent_next_line = t[:nuke_outer_whitespace] - return - end - - if parse - push_script(value, t.merge(:in_tag => true)) - concat_merged_text("" + (t[:nuke_outer_whitespace] ? "" : "\n")) - end - end - - def compile_comment - open = "" : "-->"}") - return - end - - push_text(open, 1) - @output_tabs += 1 - yield if block_given? - @output_tabs -= 1 - push_text(@node.value[:conditional] ? "" : "-->", -1) - end - - def compile_doctype - doctype = text_for_doctype - push_text doctype if doctype - end - - def compile_filter - unless filter = Filters.defined[@node.value[:name]] - raise Error.new("Filter \"#{@node.value[:name]}\" is not defined.", @node.line - 1) - end - filter.internal_compile(self, @node.value[:text]) - end - - def text_for_doctype - if @node.value[:type] == "xml" - return nil if html? - wrapper = @options[:attr_wrapper] - return "" - end - - if html5? - '' - else - if xhtml? - if @node.value[:version] == "1.1" - '' - elsif @node.value[:version] == "5" - '' - else - case @node.value[:type] - when "strict"; '' - when "frameset"; '' - when "mobile"; '' - when "rdfa"; '' - when "basic"; '' - else '' - end - end - - elsif html4? - case @node.value[:type] - when "strict"; '' - when "frameset"; '' - else '' - end - end - end - end - - # Evaluates `text` in the context of the scope object, but - # does not output the result. - def push_silent(text, can_suppress = false) - flush_merged_text - return if can_suppress && options[:suppress_eval] - @precompiled << "#{resolve_newlines}#{text}\n" - @output_line += text.count("\n") + 1 - end - - # Adds `text` to `@buffer` with appropriate tabulation - # without parsing it. - def push_merged_text(text, tab_change = 0, indent = true) - text = !indent || @dont_indent_next_line || @options[:ugly] ? text : "#{' ' * @output_tabs}#{text}" - @to_merge << [:text, text, tab_change] - @dont_indent_next_line = false - end - - # Concatenate `text` to `@buffer` without tabulation. - def concat_merged_text(text) - @to_merge << [:text, text, 0] - end - - def push_text(text, tab_change = 0) - push_merged_text("#{text}\n", tab_change) - end - - def flush_merged_text - return if @to_merge.empty? - - str = "" - mtabs = 0 - @to_merge.each do |type, val, tabs| - case type - when :text - str << inspect_obj(val)[1...-1] - mtabs += tabs - when :script - if mtabs != 0 && !@options[:ugly] - val = "_hamlout.adjust_tabs(#{mtabs}); " + val - end - str << "\#{#{val}}" - mtabs = 0 - else - raise SyntaxError.new("[HAML BUG] Undefined entry in Haml::Compiler@to_merge.") - end - end - - unless str.empty? - @precompiled << - if @options[:ugly] - "_hamlout.buffer << \"#{str}\";" - else - "_hamlout.push_text(\"#{str}\", #{mtabs}, #{@dont_tab_up_next_text.inspect});" - end - end - @to_merge = [] - @dont_tab_up_next_text = false - end - - # Causes `text` to be evaluated in the context of - # the scope object and the result to be added to `@buffer`. - # - # If `opts[:preserve_script]` is true, Haml::Helpers#find_and_flatten is run on - # the result before it is added to `@buffer` - def push_script(text, opts = {}) - return if options[:suppress_eval] - - args = %w[preserve_script in_tag preserve_tag escape_html nuke_inner_whitespace] - args.map! {|name| opts[name.to_sym]} - args << !block_given? << @options[:ugly] - - no_format = @options[:ugly] && - !(opts[:preserve_script] || opts[:preserve_tag] || opts[:escape_html]) - output_expr = "(#{text}\n)" - static_method = "_hamlout.#{static_method_name(:format_script, *args)}" - - # Prerender tabulation unless we're in a tag - push_merged_text '' unless opts[:in_tag] - - unless block_given? - push_generated_script(no_format ? "#{text}\n" : "#{static_method}(#{output_expr});") - concat_merged_text("\n") unless opts[:in_tag] || opts[:nuke_inner_whitespace] - return - end - - flush_merged_text - push_silent "haml_temp = #{text}" - yield - push_silent('end', :can_suppress) unless @node.value[:dont_push_end] - @precompiled << "_hamlout.buffer << #{no_format ? "haml_temp.to_s;" : "#{static_method}(haml_temp);"}" - concat_merged_text("\n") unless opts[:in_tag] || opts[:nuke_inner_whitespace] || @options[:ugly] - end - - def push_generated_script(text) - @to_merge << [:script, resolve_newlines + text] - @output_line += text.count("\n") - end - - # This is a class method so it can be accessed from Buffer. - def self.build_attributes(is_html, attr_wrapper, escape_attrs, attributes = {}) - quote_escape = attr_wrapper == '"' ? """ : "'" - other_quote_char = attr_wrapper == '"' ? "'" : '"' - - if attributes['data'].is_a?(Hash) - attributes = attributes.dup - attributes = - Haml::Util.map_keys(attributes.delete('data')) {|name| "data-#{name}"}.merge(attributes) - end - - result = attributes.collect do |attr, value| - next if value.nil? - - value = filter_and_join(value, ' ') if attr == 'class' - value = filter_and_join(value, '_') if attr == 'id' - - if value == true - next " #{attr}" if is_html - next " #{attr}=#{attr_wrapper}#{attr}#{attr_wrapper}" - elsif value == false - next - end - - escaped = - if escape_attrs == :once - Haml::Helpers.escape_once(value.to_s) - elsif escape_attrs - CGI.escapeHTML(value.to_s) - else - value.to_s - end - value = Haml::Helpers.preserve(escaped) - if escape_attrs - # We want to decide whether or not to escape quotes - value.gsub!('"', '"') - this_attr_wrapper = attr_wrapper - if value.include? attr_wrapper - if value.include? other_quote_char - value = value.gsub(attr_wrapper, quote_escape) - else - this_attr_wrapper = other_quote_char - end - end - else - this_attr_wrapper = attr_wrapper - end - " #{attr}=#{this_attr_wrapper}#{value}#{this_attr_wrapper}" - end - result.compact.sort.join - end - - def self.filter_and_join(value, separator) - return "" if value == "" - value = [value] unless value.is_a?(Array) - value = value.flatten.collect {|item| item ? item.to_s : nil}.compact.join(separator) - return !value.empty? && value - end - - def prerender_tag(name, self_close, attributes) - attributes_string = Compiler.build_attributes( - html?, @options[:attr_wrapper], @options[:escape_attrs], attributes) - "<#{name}#{attributes_string}#{self_close && xhtml? ? ' /' : ''}>" - end - - def resolve_newlines - diff = @node.line - @output_line - return "" if diff <= 0 - @output_line = @node.line - "\n" * [diff, 0].max - end - - # Get rid of and whitespace at the end of the buffer - # or the merged text - def rstrip_buffer!(index = -1) - last = @to_merge[index] - if last.nil? - push_silent("_hamlout.rstrip!", false) - @dont_tab_up_next_text = true - return - end - - case last.first - when :text - last[1].rstrip! - if last[1].empty? - @to_merge.slice! index - rstrip_buffer! index - end - when :script - last[1].gsub!(/\(haml_temp, (.*?)\);$/, '(haml_temp.rstrip, \1);') - rstrip_buffer! index - 1 - else - raise SyntaxError.new("[HAML BUG] Undefined entry in Haml::Compiler@to_merge.") - end - end - - def compile(node) - parent, @node = @node, node - block = proc {node.children.each {|c| compile c}} - send("compile_#{node.type}", &(block unless node.children.empty?)) - ensure - @node = parent - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/engine.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/engine.rb deleted file mode 100644 index 512c7b10ca..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/engine.rb +++ /dev/null @@ -1,312 +0,0 @@ -require 'haml/helpers' -require 'haml/buffer' -require 'haml/parser' -require 'haml/compiler' -require 'haml/filters' -require 'haml/error' - -module Haml - # This is the frontend for using Haml programmatically. - # It can be directly used by the user by creating a - # new instance and calling \{#render} to render the template. - # For example: - # - # template = File.read('templates/really_cool_template.haml') - # haml_engine = Haml::Engine.new(template) - # output = haml_engine.render - # puts output - class Engine - include Parser - include Compiler - - # The options hash. - # See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}. - # - # @return [{Symbol => Object}] - attr_accessor :options - - # The indentation used in the Haml document, - # or `nil` if the indentation is ambiguous - # (for example, for a single-level document). - # - # @return [String] - attr_accessor :indentation - - # @return [Boolean] Whether or not the format is XHTML. - def xhtml? - not html? - end - - # @return [Boolean] Whether or not the format is any flavor of HTML. - def html? - html4? or html5? - end - - # @return [Boolean] Whether or not the format is HTML4. - def html4? - @options[:format] == :html4 - end - - # @return [Boolean] Whether or not the format is HTML5. - def html5? - @options[:format] == :html5 - end - - # The source code that is evaluated to produce the Haml document. - # - # In Ruby 1.9, this is automatically converted to the correct encoding - # (see {file:HAML_REFERENCE.md#encoding-option the `:encoding` option}). - # - # @return [String] - def precompiled - return @precompiled if ruby1_8? - encoding = Encoding.find(@options[:encoding]) - return @precompiled.force_encoding(encoding) if encoding == Encoding::BINARY - return @precompiled.encode(encoding) - end - - # Precompiles the Haml template. - # - # @param template [String] The Haml template - # @param options [{Symbol => Object}] An options hash; - # see {file:HAML_REFERENCE.md#haml_options the Haml options documentation} - # @raise [Haml::Error] if there's a Haml syntax error in the template - def initialize(template, options = {}) - @options = { - :suppress_eval => false, - :attr_wrapper => "'", - - # Don't forget to update the docs in doc-src/HAML_REFERENCE.md - # if you update these - :autoclose => %w[meta img link br hr input area param col base], - :preserve => %w[textarea pre code], - - :filename => '(haml)', - :line => 1, - :ugly => false, - :format => :xhtml, - :escape_html => false, - :escape_attrs => true, - } - - - template = check_haml_encoding(template) do |msg, line| - raise Haml::Error.new(msg, line) - end - - unless ruby1_8? - @options[:encoding] = Encoding.default_internal || template.encoding - @options[:encoding] = "utf-8" if @options[:encoding].name == "US-ASCII" - end - @options.merge! options.reject {|k, v| v.nil?} - @index = 0 - - unless [:xhtml, :html4, :html5].include?(@options[:format]) - raise Haml::Error, "Invalid output format #{@options[:format].inspect}" - end - - if @options[:encoding] && @options[:encoding].is_a?(Encoding) - @options[:encoding] = @options[:encoding].name - end - - # :eod is a special end-of-document marker - @template = (template.rstrip).split(/\r\n|\r|\n/) + [:eod, :eod] - @template_index = 0 - @to_close_stack = [] - @output_tabs = 0 - @template_tabs = 0 - @flat = false - @newlines = 0 - @precompiled = '' - @to_merge = [] - @tab_change = 0 - - compile(parse) - rescue Haml::Error => e - if @index || e.line - e.backtrace.unshift "#{@options[:filename]}:#{(e.line ? e.line + 1 : @index) + @options[:line] - 1}" - end - raise - end - - # Processes the template and returns the result as a string. - # - # `scope` is the context in which the template is evaluated. - # If it's a `Binding` or `Proc` object, - # Haml uses it as the second argument to `Kernel#eval`; - # otherwise, Haml just uses its `#instance_eval` context. - # - # Note that Haml modifies the evaluation context - # (either the scope object or the `self` object of the scope binding). - # It extends {Haml::Helpers}, and various instance variables are set - # (all prefixed with `haml_`). - # For example: - # - # s = "foobar" - # Haml::Engine.new("%p= upcase").render(s) #=> "

FOOBAR

" - # - # # s now extends Haml::Helpers - # s.respond_to?(:html_attrs) #=> true - # - # `locals` is a hash of local variables to make available to the template. - # For example: - # - # Haml::Engine.new("%p= foo").render(Object.new, :foo => "Hello, world!") #=> "

Hello, world!

" - # - # If a block is passed to render, - # that block is run when `yield` is called - # within the template. - # - # Due to some Ruby quirks, - # if `scope` is a `Binding` or `Proc` object and a block is given, - # the evaluation context may not be quite what the user expects. - # In particular, it's equivalent to passing `eval("self", scope)` as `scope`. - # This won't have an effect in most cases, - # but if you're relying on local variables defined in the context of `scope`, - # they won't work. - # - # @param scope [Binding, Proc, Object] The context in which the template is evaluated - # @param locals [{Symbol => Object}] Local variables that will be made available - # to the template - # @param block [#to_proc] A block that can be yielded to within the template - # @return [String] The rendered template - def render(scope = Object.new, locals = {}, &block) - buffer = Haml::Buffer.new(scope.instance_variable_get('@haml_buffer'), options_for_buffer) - - if scope.is_a?(Binding) || scope.is_a?(Proc) - scope_object = eval("self", scope) - scope = scope_object.instance_eval{binding} if block_given? - else - scope_object = scope - scope = scope_object.instance_eval{binding} - end - - set_locals(locals.merge(:_hamlout => buffer, :_erbout => buffer.buffer), scope, scope_object) - - scope_object.instance_eval do - extend Haml::Helpers - @haml_buffer = buffer - end - - eval(precompiled + ";" + precompiled_method_return_value, - scope, @options[:filename], @options[:line]) - ensure - # Get rid of the current buffer - scope_object.instance_eval do - @haml_buffer = buffer.upper if buffer - end - end - alias_method :to_html, :render - - # Returns a proc that, when called, - # renders the template and returns the result as a string. - # - # `scope` works the same as it does for render. - # - # The first argument of the returned proc is a hash of local variable names to values. - # However, due to an unfortunate Ruby quirk, - # the local variables which can be assigned must be pre-declared. - # This is done with the `local_names` argument. - # For example: - # - # # This works - # Haml::Engine.new("%p= foo").render_proc(Object.new, :foo).call :foo => "Hello!" - # #=> "

Hello!

" - # - # # This doesn't - # Haml::Engine.new("%p= foo").render_proc.call :foo => "Hello!" - # #=> NameError: undefined local variable or method `foo' - # - # The proc doesn't take a block; any yields in the template will fail. - # - # @param scope [Binding, Proc, Object] The context in which the template is evaluated - # @param local_names [Array] The names of the locals that can be passed to the proc - # @return [Proc] The proc that will run the template - def render_proc(scope = Object.new, *local_names) - if scope.is_a?(Binding) || scope.is_a?(Proc) - scope_object = eval("self", scope) - else - scope_object = scope - scope = scope_object.instance_eval{binding} - end - - eval("Proc.new { |*_haml_locals| _haml_locals = _haml_locals[0] || {};" + - precompiled_with_ambles(local_names) + "}\n", scope, @options[:filename], @options[:line]) - end - - # Defines a method on `object` with the given name - # that renders the template and returns the result as a string. - # - # If `object` is a class or module, - # the method will instead by defined as an instance method. - # For example: - # - # t = Time.now - # Haml::Engine.new("%p\n Today's date is\n .date= self.to_s").def_method(t, :render) - # t.render #=> "

\n Today's date is\n

Fri Nov 23 18:28:29 -0800 2007
\n

\n" - # - # Haml::Engine.new(".upcased= upcase").def_method(String, :upcased_div) - # "foobar".upcased_div #=> "
FOOBAR
\n" - # - # The first argument of the defined method is a hash of local variable names to values. - # However, due to an unfortunate Ruby quirk, - # the local variables which can be assigned must be pre-declared. - # This is done with the `local_names` argument. - # For example: - # - # # This works - # obj = Object.new - # Haml::Engine.new("%p= foo").def_method(obj, :render, :foo) - # obj.render(:foo => "Hello!") #=> "

Hello!

" - # - # # This doesn't - # obj = Object.new - # Haml::Engine.new("%p= foo").def_method(obj, :render) - # obj.render(:foo => "Hello!") #=> NameError: undefined local variable or method `foo' - # - # Note that Haml modifies the evaluation context - # (either the scope object or the `self` object of the scope binding). - # It extends {Haml::Helpers}, and various instance variables are set - # (all prefixed with `haml_`). - # - # @param object [Object, Module] The object on which to define the method - # @param name [String, Symbol] The name of the method to define - # @param local_names [Array] The names of the locals that can be passed to the proc - def def_method(object, name, *local_names) - method = object.is_a?(Module) ? :module_eval : :instance_eval - - object.send(method, "def #{name}(_haml_locals = {}); #{precompiled_with_ambles(local_names)}; end", - @options[:filename], @options[:line]) - end - - protected - - # Returns a subset of \{#options}: those that {Haml::Buffer} cares about. - # All of the values here are such that when `#inspect` is called on the hash, - # it can be `Kernel#eval`ed to get the same result back. - # - # See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}. - # - # @return [{Symbol => Object}] The options hash - def options_for_buffer - { - :autoclose => @options[:autoclose], - :preserve => @options[:preserve], - :attr_wrapper => @options[:attr_wrapper], - :ugly => @options[:ugly], - :format => @options[:format], - :encoding => @options[:encoding], - :escape_html => @options[:escape_html], - :escape_attrs => @options[:escape_attrs], - } - end - - private - - def set_locals(locals, scope, scope_object) - scope_object.send(:instance_variable_set, '@_haml_locals', locals) - set_locals = locals.keys.map { |k| "#{k} = @_haml_locals[#{k.inspect}]" }.join("\n") - eval(set_locals, scope) - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/error.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/error.rb deleted file mode 100644 index b1865eaefa..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/error.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Haml - # An exception raised by Haml code. - class Error < StandardError - # The line of the template on which the error occurred. - # - # @return [Fixnum] - attr_reader :line - - # @param message [String] The error message - # @param line [Fixnum] See \{#line} - def initialize(message = nil, line = nil) - super(message) - @line = line - end - end - - # SyntaxError is the type of exception raised when Haml encounters an - # ill-formatted document. - # It's not particularly interesting, - # except in that it's a subclass of {Haml::Error}. - class SyntaxError < Haml::Error; end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/exec.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/exec.rb deleted file mode 100644 index 81eea0194f..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/exec.rb +++ /dev/null @@ -1,362 +0,0 @@ -require 'optparse' -require 'fileutils' - -module Haml - # This module handles the various Haml executables (`haml` and `haml-convert`). - module Exec - # An abstract class that encapsulates the executable code for all three executables. - class Generic - # @param args [Array] The command-line arguments - def initialize(args) - @args = args - @options = {} - end - - # Parses the command-line arguments and runs the executable. - # Calls `Kernel#exit` at the end, so it never returns. - # - # @see #parse - def parse! - begin - parse - rescue Exception => e - raise e if @options[:trace] || e.is_a?(SystemExit) - - $stderr.print "#{e.class}: " unless e.class == RuntimeError - $stderr.puts "#{e.message}" - $stderr.puts " Use --trace for backtrace." - exit 1 - end - exit 0 - end - - # Parses the command-line arguments and runs the executable. - # This does not handle exceptions or exit the program. - # - # @see #parse! - def parse - @opts = OptionParser.new(&method(:set_opts)) - @opts.parse!(@args) - - process_result - - @options - end - - # @return [String] A description of the executable - def to_s - @opts.to_s - end - - protected - - # Finds the line of the source template - # on which an exception was raised. - # - # @param exception [Exception] The exception - # @return [String] The line number - def get_line(exception) - # SyntaxErrors have weird line reporting - # when there's trailing whitespace, - # which there is for Haml documents. - return (exception.message.scan(/:(\d+)/).first || ["??"]).first if exception.is_a?(::SyntaxError) - (exception.backtrace[0].scan(/:(\d+)/).first || ["??"]).first - end - - # Tells optparse how to parse the arguments - # available for all executables. - # - # This is meant to be overridden by subclasses - # so they can add their own options. - # - # @param opts [OptionParser] - def set_opts(opts) - opts.on('-s', '--stdin', :NONE, 'Read input from standard input instead of an input file') do - @options[:input] = $stdin - end - - opts.on('--trace', :NONE, 'Show a full traceback on error') do - @options[:trace] = true - end - - opts.on('--unix-newlines', 'Use Unix-style newlines in written files.') do - @options[:unix_newlines] = true if ::Haml::Util.windows? - end - - opts.on_tail("-?", "-h", "--help", "Show this message") do - puts opts - exit - end - - opts.on_tail("-v", "--version", "Print version") do - puts("Haml #{::Haml.version[:string]}") - exit - end - end - - # Processes the options set by the command-line arguments. - # In particular, sets `@options[:input]` and `@options[:output]` - # to appropriate IO streams. - # - # This is meant to be overridden by subclasses - # so they can run their respective programs. - def process_result - input, output = @options[:input], @options[:output] - args = @args.dup - input ||= - begin - filename = args.shift - @options[:filename] = filename - open_file(filename) || $stdin - end - output ||= open_file(args.shift, 'w') || $stdout - - @options[:input], @options[:output] = input, output - end - - COLORS = { :red => 31, :green => 32, :yellow => 33 } - - # Prints a status message about performing the given action, - # colored using the given color (via terminal escapes) if possible. - # - # @param name [#to_s] A short name for the action being performed. - # Shouldn't be longer than 11 characters. - # @param color [Symbol] The name of the color to use for this action. - # Can be `:red`, `:green`, or `:yellow`. - def puts_action(name, color, arg) - return if @options[:for_engine][:quiet] - printf color(color, "%11s %s\n"), name, arg - end - - # Same as \{Kernel.puts}, but doesn't print anything if the `--quiet` option is set. - # - # @param args [Array] Passed on to \{Kernel.puts} - def puts(*args) - return if @options[:for_engine][:quiet] - Kernel.puts(*args) - end - - # Wraps the given string in terminal escapes - # causing it to have the given color. - # If terminal esapes aren't supported on this platform, - # just returns the string instead. - # - # @param color [Symbol] The name of the color to use. - # Can be `:red`, `:green`, or `:yellow`. - # @param str [String] The string to wrap in the given color. - # @return [String] The wrapped string. - def color(color, str) - raise "[BUG] Unrecognized color #{color}" unless COLORS[color] - - # Almost any real Unix terminal will support color, - # so we just filter for Windows terms (which don't set TERM) - # and not-real terminals, which aren't ttys. - return str if ENV["TERM"].nil? || ENV["TERM"].empty? || !STDOUT.tty? - return "\e[#{COLORS[color]}m#{str}\e[0m" - end - - private - - def open_file(filename, flag = 'r') - return if filename.nil? - flag = 'wb' if @options[:unix_newlines] && flag == 'w' - File.open(filename, flag) - end - - def handle_load_error(err) - dep = err.message[/^no such file to load -- (.*)/, 1] - raise err if @options[:trace] || dep.nil? || dep.empty? - $stderr.puts <] The command-line arguments - def initialize(args) - super - @options[:for_engine] = {} - @options[:requires] = [] - @options[:load_paths] = [] - end - - # Tells optparse how to parse the arguments. - # - # @param opts [OptionParser] - def set_opts(opts) - super - - opts.banner = < e - raise "#{e.is_a?(::Haml::SyntaxError) ? "Syntax error" : "Error"} on line " + - "#{get_line e}: #{e.message}" - rescue LoadError => err - handle_load_error(err) - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/filters.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/filters.rb deleted file mode 100644 index 9a3e6883ef..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/filters.rb +++ /dev/null @@ -1,385 +0,0 @@ -module Haml - # The module containing the default Haml filters, - # as well as the base module, {Haml::Filters::Base}. - # - # @see Haml::Filters::Base - module Filters - # @return [{String => Haml::Filters::Base}] a hash of filter names to classes - def self.defined - @defined ||= {} - end - - # The base module for Haml filters. - # User-defined filters should be modules including this module. - # The name of the filter is taken by downcasing the module name. - # For instance, if the module is named `FooBar`, the filter will be `:foobar`. - # - # A user-defined filter should override either \{#render} or {\#compile}. - # \{#render} is the most common. - # It takes a string, the filter source, - # and returns another string, the result of the filter. - # For example, the following will define a filter named `:sass`: - # - # module Haml::Filters::Sass - # include Haml::Filters::Base - # - # def render(text) - # ::Sass::Engine.new(text).render - # end - # end - # - # For details on overriding \{#compile}, see its documentation. - # - # Note that filters overriding \{#render} automatically support `#{}` - # for interpolating Ruby code. - # Those overriding \{#compile} will need to add such support manually - # if it's desired. - module Base - # This method is automatically called when {Base} is included in a module. - # It automatically defines a filter - # with the downcased name of that module. - # For example, if the module is named `FooBar`, the filter will be `:foobar`. - # - # @param base [Module, Class] The module that this is included in - def self.included(base) - Filters.defined[base.name.split("::").last.downcase] = base - base.extend(base) - end - - # Takes the source text that should be passed to the filter - # and returns the result of running the filter on that string. - # - # This should be overridden in most individual filter modules - # to render text with the given filter. - # If \{#compile} is overridden, however, \{#render} doesn't need to be. - # - # @param text [String] The source text for the filter to process - # @return [String] The filtered result - # @raise [Haml::Error] if it's not overridden - def render(text) - raise Error.new("#{self.inspect}#render not defined!") - end - - # Same as \{#render}, but takes a {Haml::Engine} options hash as well. - # It's only safe to rely on options made available in {Haml::Engine#options\_for\_buffer}. - # - # @see #render - # @param text [String] The source text for the filter to process - # @return [String] The filtered result - # @raise [Haml::Error] if it or \{#render} isn't overridden - def render_with_options(text, options) - render(text) - end - - # Same as \{#compile}, but requires the necessary files first. - # *This is used by {Haml::Engine} and is not intended to be overridden or used elsewhere.* - # - # @see #compile - def internal_compile(*args) - resolve_lazy_requires - compile(*args) - end - - # This should be overridden when a filter needs to have access to the Haml evaluation context. - # Rather than applying a filter to a string at compile-time, - # \{#compile} uses the {Haml::Compiler} instance to compile the string to Ruby code - # that will be executed in the context of the active Haml template. - # - # Warning: the {Haml::Compiler} interface is neither well-documented - # nor guaranteed to be stable. - # If you want to make use of it, you'll probably need to look at the source code - # and should test your filter when upgrading to new Haml versions. - # - # @param compiler [Haml::Compiler] The compiler instance - # @param text [String] The text of the filter - # @raise [Haml::Error] if none of \{#compile}, \{#render}, and \{#render_with_options} are overridden - def compile(compiler, text) - resolve_lazy_requires - filter = self - compiler.instance_eval do - if contains_interpolation?(text) - return if options[:suppress_eval] - - text = unescape_interpolation(text).gsub(/(\\+)n/) do |s| - escapes = $1.size - next s if escapes % 2 == 0 - ("\\" * (escapes - 1)) + "\n" - end - # We need to add a newline at the beginning to get the - # filter lines to line up (since the Haml filter contains - # a line that doesn't show up in the source, namely the - # filter name). Then we need to escape the trailing - # newline so that the whole filter block doesn't take up - # too many. - text = "\n" + text.sub(/\n"\Z/, "\\n\"") - push_script < false -find_and_preserve(#{filter.inspect}.render_with_options(#{text}, _hamlout.options)) -RUBY - return - end - - rendered = Haml::Helpers::find_and_preserve(filter.render_with_options(text, compiler.options), compiler.options[:preserve]) - - if !options[:ugly] - push_text(rendered.rstrip.gsub("\n", "\n#{' ' * @output_tabs}")) - else - push_text(rendered.rstrip) - end - end - end - - # This becomes a class method of modules that include {Base}. - # It allows the module to specify one or more Ruby files - # that Haml should try to require when compiling the filter. - # - # The first file specified is tried first, then the second, etc. - # If none are found, the compilation throws an exception. - # - # For example: - # - # module Haml::Filters::Markdown - # lazy_require 'rdiscount', 'peg_markdown', 'maruku', 'bluecloth' - # - # ... - # end - # - # @param reqs [Array] The requires to run - def lazy_require(*reqs) - @lazy_requires = reqs - end - - private - - def resolve_lazy_requires - return unless @lazy_requires - - @lazy_requires[0...-1].each do |req| - begin - @required = req - require @required - return - rescue LoadError; end # RCov doesn't see this, but it is run - end - - begin - @required = @lazy_requires[-1] - require @required - rescue LoadError => e - classname = self.name.match(/\w+$/)[0] - - if @lazy_requires.size == 1 - raise Error.new("Can't run #{classname} filter; required file '#{@lazy_requires.first}' not found") - else - raise Error.new("Can't run #{classname} filter; required #{@lazy_requires.map { |r| "'#{r}'" }.join(' or ')}, but none were found") - end - end - end - end - end -end - -begin - require 'rubygems' -rescue LoadError; end - -module Haml - module Filters - # Does not parse the filtered text. - # This is useful for large blocks of text without HTML tags, - # when you don't want lines starting with `.` or `-` - # to be parsed. - module Plain - include Base - - # @see Base#render - def render(text); text; end - end - - # Surrounds the filtered text with ` -END - end - end - - # Surrounds the filtered text with ` -END - end - end - - # Surrounds the filtered text with CDATA tags. - module Cdata - include Base - - # @see Base#render - def render(text) - "" - end - end - - # Works the same as {Plain}, but HTML-escapes the text - # before placing it in the document. - module Escaped - include Base - - # @see Base#render - def render(text) - Haml::Helpers.html_escape text - end - end - - # Parses the filtered text with the normal Ruby interpreter. - # All output sent to `$stdout`, such as with `puts`, - # is output into the Haml document. - # Not available if the {file:HAML_REFERENCE.md#suppress_eval-option `:suppress_eval`} option is set to true. - # The Ruby code is evaluated in the same context as the Haml template. - module Ruby - include Base - lazy_require 'stringio' - - # @see Base#compile - def compile(compiler, text) - return if compiler.options[:suppress_eval] - compiler.instance_eval do - push_silent <<-FIRST.gsub("\n", ';') + text + <<-LAST.gsub("\n", ';') - _haml_old_stdout = $stdout - $stdout = StringIO.new(_hamlout.buffer, 'a') - FIRST - _haml_old_stdout, $stdout = $stdout, _haml_old_stdout - _haml_old_stdout.close - LAST - end - end - end - - # Inserts the filtered text into the template with whitespace preserved. - # `preserve`d blocks of text aren't indented, - # and newlines are replaced with the HTML escape code for newlines, - # to preserve nice-looking output. - # - # @see Haml::Helpers#preserve - module Preserve - include Base - - # @see Base#render - def render(text) - Haml::Helpers.preserve text - end - end - - # Parses the filtered text with {Sass} to produce CSS output. - module Sass - include Base - lazy_require 'sass/plugin' - - # @see Base#render - def render(text) - ::Sass::Engine.new(text, ::Sass::Plugin.engine_options).render - end - end - - # Parses the filtered text with ERB. - # Not available if the {file:HAML_REFERENCE.md#suppress_eval-option `:suppress_eval`} option is set to true. - # Embedded Ruby code is evaluated in the same context as the Haml template. - module ERB - include Base - lazy_require 'erb' - - # @see Base#compile - def compile(compiler, text) - return if compiler.options[:suppress_eval] - src = ::ERB.new(text).src.sub(/^#coding:.*?\n/, ''). - sub(/^_erbout = '';/, "") - compiler.send(:push_silent, src) - end - end - - # Parses the filtered text with [Textile](http://www.textism.com/tools/textile). - # Only works if [RedCloth](http://redcloth.org) is installed. - module Textile - include Base - lazy_require 'redcloth' - - # @see Base#render - def render(text) - ::RedCloth.new(text).to_html(:textile) - end - end - # An alias for the Textile filter, - # since the only available Textile parser is RedCloth. - # @api public - RedCloth = Textile - Filters.defined['redcloth'] = RedCloth - - # Parses the filtered text with [Markdown](http://daringfireball.net/projects/markdown). - # Only works if [RDiscount](http://github.com/rtomayko/rdiscount), - # [RPeg-Markdown](http://github.com/rtomayko/rpeg-markdown), - # [Maruku](http://maruku.rubyforge.org), - # or [BlueCloth](www.deveiate.org/projects/BlueCloth) are installed. - module Markdown - include Base - lazy_require 'rdiscount', 'peg_markdown', 'maruku', 'bluecloth' - - # @see Base#render - def render(text) - engine = case @required - when 'rdiscount' - ::RDiscount - when 'peg_markdown' - ::PEGMarkdown - when 'maruku' - ::Maruku - when 'bluecloth' - ::BlueCloth - end - engine.new(text).to_html - end - end - - # Parses the filtered text with [Maruku](http://maruku.rubyforge.org), - # which has some non-standard extensions to Markdown. - module Maruku - include Base - lazy_require 'maruku' - - # @see Base#render - def render(text) - ::Maruku.new(text).to_html - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers.rb deleted file mode 100644 index ec527cdef7..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers.rb +++ /dev/null @@ -1,606 +0,0 @@ -module Haml - # This module contains various helpful methods to make it easier to do various tasks. - # {Haml::Helpers} is automatically included in the context - # that a Haml template is parsed in, so all these methods are at your - # disposal from within the template. - module Helpers - # An object that raises an error when \{#to\_s} is called. - # It's used to raise an error when the return value of a helper is used - # when it shouldn't be. - class ErrorReturn - # @param message [String] The error message to raise when \{#to\_s} is called - def initialize(method) - @message = < e - e.backtrace.shift - - # If the ErrorReturn is used directly in the template, - # we don't want Haml's stuff to get into the backtrace, - # so we get rid of the format_script line. - # - # We also have to subtract one from the Haml line number - # since the value is passed to format_script the line after - # it's actually used. - if e.backtrace.first =~ /^\(eval\):\d+:in `format_script/ - e.backtrace.shift - e.backtrace.first.gsub!(/^\(haml\):(\d+)/) {|s| "(haml):#{$1.to_i - 1}"} - end - raise e - end - - # @return [String] A human-readable string representation - def inspect - "Haml::Helpers::ErrorReturn(#{@message.inspect})" - end - end - - self.extend self - - @@action_view_defined = false - - # @return [Boolean] Whether or not ActionView is loaded - def self.action_view? - @@action_view_defined - end - - # Note: this does **not** need to be called when using Haml helpers - # normally in Rails. - # - # Initializes the current object as though it were in the same context - # as a normal ActionView instance using Haml. - # This is useful if you want to use the helpers in a context - # other than the normal setup with ActionView. - # For example: - # - # context = Object.new - # class << context - # include Haml::Helpers - # end - # context.init_haml_helpers - # context.haml_tag :p, "Stuff" - # - def init_haml_helpers - @haml_buffer = Haml::Buffer.new(@haml_buffer, Haml::Engine.new('').send(:options_for_buffer)) - nil - end - - # Runs a block of code in a non-Haml context - # (i.e. \{#is\_haml?} will return false). - # - # This is mainly useful for rendering sub-templates such as partials in a non-Haml language, - # particularly where helpers may behave differently when run from Haml. - # - # Note that this is automatically applied to Rails partials. - # - # @yield A block which won't register as Haml - def non_haml - was_active = @haml_buffer.active? - @haml_buffer.active = false - yield - ensure - @haml_buffer.active = was_active - end - - # Uses \{#preserve} to convert any newlines inside whitespace-sensitive tags - # into the HTML entities for endlines. - # - # @param tags [Array] Tags that should have newlines escaped - # - # @overload find_and_preserve(input, tags = haml_buffer.options[:preserve]) - # Escapes newlines within a string. - # - # @param input [String] The string within which to escape newlines - # @overload find_and_preserve(tags = haml_buffer.options[:preserve]) - # Escapes newlines within a block of Haml code. - # - # @yield The block within which to escape newlines - def find_and_preserve(input = nil, tags = haml_buffer.options[:preserve], &block) - return find_and_preserve(capture_haml(&block), input || tags) if block - input.to_s.gsub(/<(#{tags.map(&Regexp.method(:escape)).join('|')})([^>]*)>(.*?)(<\/\1>)/im) do - "<#{$1}#{$2}>#{preserve($3)}" - end - end - - # Takes any string, finds all the newlines, and converts them to - # HTML entities so they'll render correctly in - # whitespace-sensitive tags without screwing up the indentation. - # - # @overload perserve(input) - # Escapes newlines within a string. - # - # @param input [String] The string within which to escape all newlines - # @overload perserve - # Escapes newlines within a block of Haml code. - # - # @yield The block within which to escape newlines - def preserve(input = nil, &block) - return preserve(capture_haml(&block)) if block - input.to_s.chomp("\n").gsub(/\n/, ' ').gsub(/\r/, '') - end - alias_method :flatten, :preserve - - # Takes an `Enumerable` object and a block - # and iterates over the enum, - # yielding each element to a Haml block - # and putting the result into `
  • ` elements. - # This creates a list of the results of the block. - # For example: - # - # = list_of([['hello'], ['yall']]) do |i| - # = i[0] - # - # Produces: - # - #
  • hello
  • - #
  • yall
  • - # - # And - # - # = list_of({:title => 'All the stuff', :description => 'A book about all the stuff.'}) do |key, val| - # %h3= key.humanize - # %p= val - # - # Produces: - # - #
  • - #

    Title

    - #

    All the stuff

    - #
  • - #
  • - #

    Description

    - #

    A book about all the stuff.

    - #
  • - # - # @param enum [Enumerable] The list of objects to iterate over - # @yield [item] A block which contains Haml code that goes within list items - # @yieldparam item An element of `enum` - def list_of(enum, &block) - to_return = enum.collect do |i| - result = capture_haml(i, &block) - - if result.count("\n") > 1 - result.gsub!("\n", "\n ") - result = "\n #{result.strip}\n" - else - result.strip! - end - - "
  • #{result}
  • " - end - to_return.join("\n") - end - - # Returns a hash containing default assignments for the `xmlns`, `lang`, and `xml:lang` - # attributes of the `html` HTML element. - # For example, - # - # %html{html_attrs} - # - # becomes - # - # - # - # @param lang [String] The value of `xml:lang` and `lang` - # @return [{#to_s => String}] The attribute hash - def html_attrs(lang = 'en-US') - {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang} - end - - # Increments the number of tabs the buffer automatically adds - # to the lines of the template. - # For example: - # - # %h1 foo - # - tab_up - # %p bar - # - tab_down - # %strong baz - # - # Produces: - # - #

    foo

    - #

    bar

    - # baz - # - # @param i [Fixnum] The number of tabs by which to increase the indentation - # @see #tab_down - def tab_up(i = 1) - haml_buffer.tabulation += i - end - - # Decrements the number of tabs the buffer automatically adds - # to the lines of the template. - # - # @param i [Fixnum] The number of tabs by which to decrease the indentation - # @see #tab_up - def tab_down(i = 1) - haml_buffer.tabulation -= i - end - - # Sets the number of tabs the buffer automatically adds - # to the lines of the template, - # but only for the duration of the block. - # For example: - # - # %h1 foo - # - with_tabs(2) do - # %p bar - # %strong baz - # - # Produces: - # - #

    foo

    - #

    bar

    - # baz - # - # - # @param i [Fixnum] The number of tabs to use - # @yield A block in which the indentation will be `i` spaces - def with_tabs(i) - old_tabs = haml_buffer.tabulation - haml_buffer.tabulation = i - yield - ensure - haml_buffer.tabulation = old_tabs - end - - # Surrounds a block of Haml code with strings, - # with no whitespace in between. - # For example: - # - # = surround '(', ')' do - # %a{:href => "food"} chicken - # - # Produces: - # - # (chicken) - # - # and - # - # = surround '*' do - # %strong angry - # - # Produces: - # - # *angry* - # - # @param front [String] The string to add before the Haml - # @param back [String] The string to add after the Haml - # @yield A block of Haml to surround - def surround(front, back = front, &block) - output = capture_haml(&block) - - "#{front}#{output.chomp}#{back}\n" - end - - # Prepends a string to the beginning of a Haml block, - # with no whitespace between. - # For example: - # - # = precede '*' do - # %span.small Not really - # - # Produces: - # - # *Not really - # - # @param str [String] The string to add before the Haml - # @yield A block of Haml to prepend to - def precede(str, &block) - "#{str}#{capture_haml(&block).chomp}\n" - end - - # Appends a string to the end of a Haml block, - # with no whitespace between. - # For example: - # - # click - # = succeed '.' do - # %a{:href=>"thing"} here - # - # Produces: - # - # click - # here. - # - # @param str [String] The string to add after the Haml - # @yield A block of Haml to append to - def succeed(str, &block) - "#{capture_haml(&block).chomp}#{str}\n" - end - - # Captures the result of a block of Haml code, - # gets rid of the excess indentation, - # and returns it as a string. - # For example, after the following, - # - # .foo - # - foo = capture_haml(13) do |a| - # %p= a - # - # the local variable `foo` would be assigned to `"

    13

    \n"`. - # - # @param args [Array] Arguments to pass into the block - # @yield [args] A block of Haml code that will be converted to a string - # @yieldparam args [Array] `args` - def capture_haml(*args, &block) - buffer = eval('_hamlout', block.binding) rescue haml_buffer - with_haml_buffer(buffer) do - position = haml_buffer.buffer.length - - haml_buffer.capture_position = position - block.call(*args) - - captured = haml_buffer.buffer.slice!(position..-1) - return captured if haml_buffer.options[:ugly] - captured = captured.split(/^/) - - min_tabs = nil - captured.each do |line| - tabs = line.index(/[^ ]/) || line.length - min_tabs ||= tabs - min_tabs = min_tabs > tabs ? tabs : min_tabs - end - - captured.map do |line| - line[min_tabs..-1] - end.join - end - ensure - haml_buffer.capture_position = nil - end - - # Outputs text directly to the Haml buffer, with the proper indentation. - # - # @param text [#to_s] The text to output - def haml_concat(text = "") - unless haml_buffer.options[:ugly] || haml_indent == 0 - haml_buffer.buffer << haml_indent << - text.to_s.gsub("\n", "\n" + haml_indent) << "\n" - else - haml_buffer.buffer << text.to_s << "\n" - end - ErrorReturn.new("haml_concat") - end - - # @return [String] The indentation string for the current line - def haml_indent - ' ' * haml_buffer.tabulation - end - - # Creates an HTML tag with the given name and optionally text and attributes. - # Can take a block that will run between the opening and closing tags. - # If the block is a Haml block or outputs text using \{#haml\_concat}, - # the text will be properly indented. - # - # `name` can be a string using the standard Haml class/id shorthand - # (e.g. "span#foo.bar", "#foo"). - # Just like standard Haml tags, these class and id values - # will be merged with manually-specified attributes. - # - # `flags` is a list of symbol flags - # like those that can be put at the end of a Haml tag - # (`:/`, `:<`, and `:>`). - # Currently, only `:/` and `:<` are supported. - # - # `haml_tag` outputs directly to the buffer; - # its return value should not be used. - # If you need to get the results as a string, - # use \{#capture\_haml\}. - # - # For example, - # - # haml_tag :table do - # haml_tag :tr do - # haml_tag 'td.cell' do - # haml_tag :strong, "strong!" - # haml_concat "data" - # end - # haml_tag :td do - # haml_concat "more_data" - # end - # end - # end - # - # outputs - # - # - # - # - # - # - #
    - # - # strong! - # - # data - # - # more_data - #
    - # - # @param name [#to_s] The name of the tag - # @param flags [Array] Haml end-of-tag flags - # - # @overload haml_tag(name, *flags, attributes = {}) - # @yield The block of Haml code within the tag - # @overload haml_tag(name, text, *flags, attributes = {}) - # @param text [#to_s] The text within the tag - def haml_tag(name, *rest, &block) - ret = ErrorReturn.new("haml_tag") - - text = rest.shift.to_s unless [Symbol, Hash, NilClass].any? {|t| rest.first.is_a? t} - flags = [] - flags << rest.shift while rest.first.is_a? Symbol - attrs = Haml::Util.map_keys(rest.shift || {}) {|key| key.to_s} - name, attrs = merge_name_and_attributes(name.to_s, attrs) - - attributes = Haml::Compiler.build_attributes(haml_buffer.html?, - haml_buffer.options[:attr_wrapper], - haml_buffer.options[:escape_attrs], - attrs) - - if text.nil? && block.nil? && (haml_buffer.options[:autoclose].include?(name) || flags.include?(:/)) - haml_concat "<#{name}#{attributes} />" - return ret - end - - if flags.include?(:/) - raise Error.new("Self-closing tags can't have content.") if text - raise Error.new("Illegal nesting: nesting within a self-closing tag is illegal.") if block - end - - tag = "<#{name}#{attributes}>" - if block.nil? - text = text.to_s - if text.include?("\n") - haml_concat tag - tab_up - haml_concat text - tab_down - haml_concat "" - else - tag << text << "" - haml_concat tag - end - return ret - end - - if text - raise Error.new("Illegal nesting: content can't be both given to haml_tag :#{name} and nested within it.") - end - - if flags.include?(:<) - tag << capture_haml(&block).strip << "" - haml_concat tag - return ret - end - - haml_concat tag - tab_up - block.call - tab_down - haml_concat "" - - ret - end - - # Characters that need to be escaped to HTML entities from user input - HTML_ESCAPE = { '&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"', "'"=>''', } - - # Returns a copy of `text` with ampersands, angle brackets and quotes - # escaped into HTML entities. - # - # Note that if ActionView is loaded and XSS protection is enabled - # (as is the default for Rails 3.0+, and optional for version 2.3.5+), - # this won't escape text declared as "safe". - # - # @param text [String] The string to sanitize - # @return [String] The sanitized string - def html_escape(text) - Haml::Util.silence_warnings {text.to_s.gsub(/[\"><&]/n) {|s| HTML_ESCAPE[s]}} - end - - # Escapes HTML entities in `text`, but without escaping an ampersand - # that is already part of an escaped entity. - # - # @param text [String] The string to sanitize - # @return [String] The sanitized string - def escape_once(text) - Haml::Util.silence_warnings do - text.to_s.gsub(/[\"><]|&(?!(?:[a-zA-Z]+|(#\d+));)/n) {|s| HTML_ESCAPE[s]} - end - end - - # Returns whether or not the current template is a Haml template. - # - # This function, unlike other {Haml::Helpers} functions, - # also works in other `ActionView` templates, - # where it will always return false. - # - # @return [Boolean] Whether or not the current template is a Haml template - def is_haml? - !@haml_buffer.nil? && @haml_buffer.active? - end - - # Returns whether or not `block` is defined directly in a Haml template. - # - # @param block [Proc] A Ruby block - # @return [Boolean] Whether or not `block` is defined directly in a Haml template - def block_is_haml?(block) - eval('_hamlout', block.binding) - true - rescue - false - end - - private - - # Parses the tag name used for \{#haml\_tag} - # and merges it with the Ruby attributes hash. - def merge_name_and_attributes(name, attributes_hash = {}) - # skip merging if no ids or classes found in name - return name, attributes_hash unless name =~ /^(.+?)?([\.#].*)$/ - - return $1 || "div", Buffer.merge_attrs( - Haml::Parser.parse_class_and_id($2), attributes_hash) - end - - # Runs a block of code with the given buffer as the currently active buffer. - # - # @param buffer [Haml::Buffer] The Haml buffer to use temporarily - # @yield A block in which the given buffer should be used - def with_haml_buffer(buffer) - @haml_buffer, old_buffer = buffer, @haml_buffer - old_buffer.active, old_was_active = false, old_buffer.active? if old_buffer - @haml_buffer.active, was_active = true, @haml_buffer.active? - yield - ensure - @haml_buffer.active = was_active - old_buffer.active = old_was_active if old_buffer - @haml_buffer = old_buffer - end - - # The current {Haml::Buffer} object. - # - # @return [Haml::Buffer] - def haml_buffer - @haml_buffer - end - - # Gives a proc the same local `_hamlout` and `_erbout` variables - # that the current template has. - # - # @param proc [#call] The proc to bind - # @return [Proc] A new proc with the new variables bound - def haml_bind_proc(&proc) - _hamlout = haml_buffer - _erbout = _hamlout.buffer - proc { |*args| proc.call(*args) } - end - end -end - -# @private -class Object - # Haml overrides various `ActionView` helpers, - # which call an \{#is\_haml?} method - # to determine whether or not the current context object - # is a proper Haml context. - # Because `ActionView` helpers may be included in non-`ActionView::Base` classes, - # it's a good idea to define \{#is\_haml?} for all objects. - def is_haml? - false - end -end - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/action_view_extensions.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/action_view_extensions.rb deleted file mode 100644 index afd0786da3..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/action_view_extensions.rb +++ /dev/null @@ -1,57 +0,0 @@ -module Haml - module Helpers - @@action_view_defined = true - - # This module contains various useful helper methods - # that either tie into ActionView or the rest of the ActionPack stack, - # or are only useful in that context. - # Thus, the methods defined here are only available - # if ActionView is installed. - module ActionViewExtensions - # Returns a value for the "class" attribute - # unique to this controller/action pair. - # This can be used to target styles specifically at this action or controller. - # For example, if the current action were `EntryController#show`, - # - # %div{:class => page_class} My Div - # - # would become - # - #
    My Div
    - # - # Then, in a stylesheet (shown here as [Sass](http://sass-lang.com)), - # you could refer to this specific action: - # - # .entry.show - # font-weight: bold - # - # or to all actions in the entry controller: - # - # .entry - # color: #00f - # - # @return [String] The class name for the current page - def page_class - controller.controller_name + " " + controller.action_name - end - alias_method :generate_content_class_names, :page_class - - # Treats all input to \{Haml::Helpers#haml\_concat} within the block - # as being HTML safe for Rails' XSS protection. - # This is useful for wrapping blocks of code that concatenate HTML en masse. - # - # This has no effect if Rails' XSS protection isn't enabled. - # - # @yield A block in which all input to `#haml_concat` is treated as raw. - # @see Haml::Util#rails_xss_safe? - def with_raw_haml_concat - @_haml_concat_raw, old = true, @_haml_concat_raw - yield - ensure - @_haml_concat_raw = old - end - end - - include ActionViewExtensions - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/action_view_mods.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/action_view_mods.rb deleted file mode 100644 index 6d33d454e1..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/action_view_mods.rb +++ /dev/null @@ -1,244 +0,0 @@ -module ActionView - class Base - def render_with_haml(*args, &block) - options = args.first - - # If render :layout is used with a block, - # it concats rather than returning a string - # so we need it to keep thinking it's Haml - # until it hits the sub-render - if is_haml? && !(options.is_a?(Hash) && options[:layout] && block_given?) - return non_haml { render_without_haml(*args, &block) } - end - render_without_haml(*args, &block) - end - alias_method :render_without_haml, :render - alias_method :render, :render_with_haml - - # Rails >2.1 - if Haml::Util.has?(:instance_method, self, :output_buffer) - def output_buffer_with_haml - return haml_buffer.buffer if is_haml? - output_buffer_without_haml - end - alias_method :output_buffer_without_haml, :output_buffer - alias_method :output_buffer, :output_buffer_with_haml - - def set_output_buffer_with_haml(new) - if is_haml? - new = String.new(new) if Haml::Util.rails_xss_safe? && - new.is_a?(Haml::Util.rails_safe_buffer_class) - haml_buffer.buffer = new - else - set_output_buffer_without_haml new - end - end - alias_method :set_output_buffer_without_haml, :output_buffer= - alias_method :output_buffer=, :set_output_buffer_with_haml - end - end - - module Helpers - # In Rails <=2.1, we've got to override considerable capturing infrastructure. - # In Rails >2.1, we can make do with only overriding #capture - # (which no longer behaves differently in helper contexts). - unless Haml::Util.has?(:instance_method, ActionView::Base, :output_buffer) - module CaptureHelper - def capture_with_haml(*args, &block) - # Rails' #capture helper will just return the value of the block - # if it's not actually in the template context, - # as detected by the existance of an _erbout variable. - # We've got to do the same thing for compatibility. - - if is_haml? && block_is_haml?(block) - capture_haml(*args, &block) - else - capture_without_haml(*args, &block) - end - end - alias_method :capture_without_haml, :capture - alias_method :capture, :capture_with_haml - - def capture_erb_with_buffer_with_haml(buffer, *args, &block) - if is_haml? - capture_haml(*args, &block) - else - capture_erb_with_buffer_without_haml(buffer, *args, &block) - end - end - alias_method :capture_erb_with_buffer_without_haml, :capture_erb_with_buffer - alias_method :capture_erb_with_buffer, :capture_erb_with_buffer_with_haml - end - - module TextHelper - def concat_with_haml(string, binding = nil) - if is_haml? - haml_buffer.buffer.concat(string) - else - concat_without_haml(string, binding) - end - end - alias_method :concat_without_haml, :concat - alias_method :concat, :concat_with_haml - end - else - module CaptureHelper - def capture_with_haml(*args, &block) - if Haml::Helpers.block_is_haml?(block) - str = capture_haml(*args, &block) - return ActionView::NonConcattingString.new(str) if defined?(ActionView::NonConcattingString) - return str - else - capture_without_haml(*args, &block) - end - end - alias_method :capture_without_haml, :capture - alias_method :capture, :capture_with_haml - end - end - - module TagHelper - def content_tag_with_haml(name, *args, &block) - return content_tag_without_haml(name, *args, &block) unless is_haml? - - preserve = haml_buffer.options[:preserve].include?(name.to_s) - - if block_given? && block_is_haml?(block) && preserve - return content_tag_without_haml(name, *args) {preserve(&block)} - end - - content = content_tag_without_haml(name, *args, &block) - content = Haml::Helpers.preserve(content) if preserve && content - content - end - - alias_method :content_tag_without_haml, :content_tag - alias_method :content_tag, :content_tag_with_haml - end - - class InstanceTag - # Includes TagHelper - - def haml_buffer - @template_object.send :haml_buffer - end - - def is_haml? - @template_object.send :is_haml? - end - - def content_tag(*args) - html_tag = content_tag_with_haml(*args) - return html_tag unless respond_to?(:error_wrapping) - return error_wrapping(html_tag) if method(:error_wrapping).arity == 1 - return html_tag unless object.respond_to?(:errors) && object.errors.respond_to?(:on) - return error_wrapping(html_tag, object.errors.on(@method_name)) - end - end - - if Haml::Util.ap_geq_3? - module FormTagHelper - def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc) - if is_haml? - wrap_block = block_given? && block_is_haml?(proc) - if wrap_block - oldproc = proc - proc = haml_bind_proc do |*args| - concat "\n" - with_tabs(1) {oldproc.call(*args)} - end - end - res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n" - res << "\n" if wrap_block - res - else - form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) - end - end - alias_method :form_tag_without_haml, :form_tag - alias_method :form_tag, :form_tag_with_haml - end - - module FormHelper - def form_for_with_haml(object_name, *args, &proc) - wrap_block = block_given? && is_haml? && block_is_haml?(proc) - if wrap_block - oldproc = proc - proc = proc {|*args| with_tabs(1) {oldproc.call(*args)}} - end - res = form_for_without_haml(object_name, *args, &proc) - res << "\n" if wrap_block - res - end - alias_method :form_for_without_haml, :form_for - alias_method :form_for, :form_for_with_haml - end - - module CacheHelper - # This is a workaround for a Rails 3 bug - # that's present at least through beta 3. - # Their fragment_for assumes that the block - # will return its contents as a string, - # which is not always the case. - # Luckily, it only makes this assumption if caching is disabled, - # so we only override that case. - def fragment_for_with_haml(*args, &block) - return fragment_for_without_haml(*args, &block) if controller.perform_caching - capture(&block) - end - alias_method :fragment_for_without_haml, :fragment_for - alias_method :fragment_for, :fragment_for_with_haml - end - else - module FormTagHelper - def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc) - if is_haml? - wrap_block = block_given? && block_is_haml?(proc) - if wrap_block - oldproc = proc - proc = haml_bind_proc do |*args| - concat "\n" - tab_up - oldproc.call(*args) - tab_down - concat haml_indent - end - concat haml_indent - end - res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n" - if block_given? - concat "\n" - return Haml::Helpers::ErrorReturn.new("form_tag") - end - res - else - form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) - end - end - alias_method :form_tag_without_haml, :form_tag - alias_method :form_tag, :form_tag_with_haml - end - - module FormHelper - def form_for_with_haml(object_name, *args, &proc) - wrap_block = block_given? && is_haml? && block_is_haml?(proc) - if wrap_block - oldproc = proc - proc = haml_bind_proc do |*args| - tab_up - oldproc.call(*args) - tab_down - concat haml_indent - end - concat haml_indent - end - form_for_without_haml(object_name, *args, &proc) - concat "\n" if wrap_block - Haml::Helpers::ErrorReturn.new("form_for") if is_haml? - end - alias_method :form_for_without_haml, :form_for - alias_method :form_for, :form_for_with_haml - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/xss_mods.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/xss_mods.rb deleted file mode 100644 index f57ac2b93d..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/helpers/xss_mods.rb +++ /dev/null @@ -1,165 +0,0 @@ -module Haml - module Helpers - # This module overrides Haml helpers to work properly - # in the context of ActionView. - # Currently it's only used for modifying the helpers - # to work with Rails' XSS protection methods. - module XssMods - def self.included(base) - %w[html_escape find_and_preserve preserve list_of surround - precede succeed capture_haml haml_concat haml_indent - haml_tag escape_once].each do |name| - base.send(:alias_method, "#{name}_without_haml_xss", name) - base.send(:alias_method, name, "#{name}_with_haml_xss") - end - end - - # Don't escape text that's already safe, - # output is always HTML safe - def html_escape_with_haml_xss(text) - str = text.to_s - return text if str.html_safe? - Haml::Util.html_safe(html_escape_without_haml_xss(str)) - end - - # Output is always HTML safe - def find_and_preserve_with_haml_xss(*args, &block) - Haml::Util.html_safe(find_and_preserve_without_haml_xss(*args, &block)) - end - - # Output is always HTML safe - def preserve_with_haml_xss(*args, &block) - Haml::Util.html_safe(preserve_without_haml_xss(*args, &block)) - end - - # Output is always HTML safe - def list_of_with_haml_xss(*args, &block) - Haml::Util.html_safe(list_of_without_haml_xss(*args, &block)) - end - - # Input is escaped, output is always HTML safe - def surround_with_haml_xss(front, back = front, &block) - Haml::Util.html_safe( - surround_without_haml_xss( - haml_xss_html_escape(front), - haml_xss_html_escape(back), - &block)) - end - - # Input is escaped, output is always HTML safe - def precede_with_haml_xss(str, &block) - Haml::Util.html_safe(precede_without_haml_xss(haml_xss_html_escape(str), &block)) - end - - # Input is escaped, output is always HTML safe - def succeed_with_haml_xss(str, &block) - Haml::Util.html_safe(succeed_without_haml_xss(haml_xss_html_escape(str), &block)) - end - - # Output is always HTML safe - def capture_haml_with_haml_xss(*args, &block) - Haml::Util.html_safe(capture_haml_without_haml_xss(*args, &block)) - end - - # Input is escaped - def haml_concat_with_haml_xss(text = "") - haml_concat_without_haml_xss(@_haml_concat_raw ? text : haml_xss_html_escape(text)) - end - - # Output is always HTML safe - def haml_indent_with_haml_xss - Haml::Util.html_safe(haml_indent_without_haml_xss) - end - - # Input is escaped, haml_concat'ed output is always HTML safe - def haml_tag_with_haml_xss(name, *rest, &block) - name = haml_xss_html_escape(name.to_s) - rest.unshift(haml_xss_html_escape(rest.shift.to_s)) unless [Symbol, Hash, NilClass].any? {|t| rest.first.is_a? t} - with_raw_haml_concat {haml_tag_without_haml_xss(name, *rest, &block)} - end - - # Output is always HTML safe - def escape_once_with_haml_xss(*args) - Haml::Util.html_safe(escape_once_without_haml_xss(*args)) - end - - private - - # Escapes the HTML in the text if and only if - # Rails XSS protection is enabled *and* the `:escape_html` option is set. - def haml_xss_html_escape(text) - return text unless Haml::Util.rails_xss_safe? && haml_buffer.options[:escape_html] - html_escape(text) - end - end - - class ErrorReturn - # Any attempt to treat ErrorReturn as a string should cause it to blow up. - alias_method :html_safe, :to_s - alias_method :html_safe?, :to_s - alias_method :html_safe!, :to_s - end - end -end - -module ActionView - module Helpers - module CaptureHelper - def with_output_buffer_with_haml_xss(*args, &block) - res = with_output_buffer_without_haml_xss(*args, &block) - case res - when Array; res.map {|s| Haml::Util.html_safe(s)} - when String; Haml::Util.html_safe(res) - else; res - end - end - alias_method :with_output_buffer_without_haml_xss, :with_output_buffer - alias_method :with_output_buffer, :with_output_buffer_with_haml_xss - end - - module FormTagHelper - def form_tag_with_haml_xss(*args, &block) - res = form_tag_without_haml_xss(*args, &block) - res = Haml::Util.html_safe(res) unless block_given? - res - end - alias_method :form_tag_without_haml_xss, :form_tag - alias_method :form_tag, :form_tag_with_haml_xss - end - - module FormHelper - def form_for_with_haml_xss(*args, &block) - res = form_for_without_haml_xss(*args, &block) - return Haml::Util.html_safe(res) if res.is_a?(String) - return res - end - alias_method :form_for_without_haml_xss, :form_for - alias_method :form_for, :form_for_with_haml_xss - end - - module TextHelper - def concat_with_haml_xss(string) - if is_haml? - haml_buffer.buffer.concat(haml_xss_html_escape(string)) - else - concat_without_haml_xss(string) - end - end - alias_method :concat_without_haml_xss, :concat - alias_method :concat, :concat_with_haml_xss - - # safe_concat was introduced in Rails 3.0 - if Haml::Util.has?(:instance_method, self, :safe_concat) - def safe_concat_with_haml_xss(string) - if is_haml? - haml_buffer.buffer.concat(string) - else - safe_concat_without_haml_xss(string) - end - end - alias_method :safe_concat_without_haml_xss, :safe_concat - alias_method :safe_concat, :safe_concat_with_haml_xss - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/html.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/html.rb deleted file mode 100644 index 7661652b77..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/html.rb +++ /dev/null @@ -1,412 +0,0 @@ -require File.dirname(__FILE__) + '/../haml' - -require 'haml/engine' -require 'rubygems' -require 'cgi' -require 'hpricot' - -# Haml monkeypatches various Hpricot classes -# to add methods for conversion to Haml. -# @private -module Hpricot - # @see Hpricot - module Node - # Whether this node has already been converted to Haml. - # Only used for text nodes and elements. - # - # @return [Boolean] - attr_accessor :converted_to_haml - - # Returns the Haml representation of the given node. - # - # @param tabs [Fixnum] The indentation level of the resulting Haml. - # @option options (see Haml::HTML#initialize) - def to_haml(tabs, options) - return "" if converted_to_haml || to_s.strip.empty? - text = uninterp(self.to_s) - node = next_node - while node.is_a?(::Hpricot::Elem) && node.name == "haml:loud" - node.converted_to_haml = true - text << '#{' << - CGI.unescapeHTML(node.inner_text).gsub(/\n\s*/, ' ').strip << '}' - - if node.next_node.is_a?(::Hpricot::Text) - node = node.next_node - text << uninterp(node.to_s) - node.converted_to_haml = true - end - - node = node.next_node - end - return parse_text_with_interpolation(text, tabs) - end - - private - - def erb_to_interpolation(text, options) - return text unless options[:erb] - text = CGI.escapeHTML(uninterp(text)) - %w[ ].each {|str| text.gsub!(CGI.escapeHTML(str), str)} - ::Hpricot::XML(text).children.inject("") do |str, elem| - if elem.is_a?(::Hpricot::Text) - str + CGI.unescapeHTML(elem.to_s) - else # element - str + '#{' + CGI.unescapeHTML(elem.innerText.strip) + '}' - end - end - end - - def tabulate(tabs) - ' ' * tabs - end - - def uninterp(text) - text.gsub('#{', '\#{') #' - end - - def attr_hash - attributes.to_hash - end - - def parse_text(text, tabs) - parse_text_with_interpolation(uninterp(text), tabs) - end - - def parse_text_with_interpolation(text, tabs) - text.strip! - return "" if text.empty? - - text.split("\n").map do |line| - line.strip! - "#{tabulate(tabs)}#{'\\' if Haml::Engine::SPECIAL_CHARACTERS.include?(line[0])}#{line}\n" - end.join - end - end -end - -# @private -HAML_TAGS = %w[haml:block haml:loud haml:silent] - -HAML_TAGS.each do |t| - Hpricot::ElementContent[t] = {} - Hpricot::ElementContent.keys.each do |key| - Hpricot::ElementContent[t][key.hash] = true - end -end - -Hpricot::ElementContent.keys.each do |k| - HAML_TAGS.each do |el| - val = Hpricot::ElementContent[k] - val[el.hash] = true if val.is_a?(Hash) - end -end - -module Haml - # Converts HTML documents into Haml templates. - # Depends on [Hpricot](http://github.com/whymirror/hpricot) for HTML parsing. - # If ERB conversion is being used, also depends on - # [Erubis](http://www.kuwata-lab.com/erubis) to parse the ERB - # and [ruby_parser](http://parsetree.rubyforge.org/) to parse the Ruby code. - # - # Example usage: - # - # Haml::HTML.new("Blat").render - # #=> "%a{:href => 'http://google.com'} Blat" - class HTML - # @param template [String, Hpricot::Node] The HTML template to convert - # @option options :erb [Boolean] (false) Whether or not to parse - # ERB's `<%= %>` and `<% %>` into Haml's `=` and `-` - # @option options :xhtml [Boolean] (false) Whether or not to parse - # the HTML strictly as XHTML - def initialize(template, options = {}) - @options = options - - if template.is_a? Hpricot::Node - @template = template - else - if template.is_a? IO - template = template.read - end - - template = Haml::Util.check_encoding(template) {|msg, line| raise Haml::Error.new(msg, line)} - - if @options[:erb] - require 'haml/html/erb' - template = ERB.compile(template) - end - - method = @options[:xhtml] ? Hpricot.method(:XML) : method(:Hpricot) - @template = method.call(template.gsub('&', '&')) - end - end - - # Processes the document and returns the result as a string - # containing the Haml template. - def render - @template.to_haml(0, @options) - end - alias_method :to_haml, :render - - TEXT_REGEXP = /^(\s*).*$/ - - # @see Hpricot - # @private - class ::Hpricot::Doc - # @see Haml::HTML::Node#to_haml - def to_haml(tabs, options) - (children || []).inject('') {|s, c| s << c.to_haml(0, options)} - end - end - - # @see Hpricot - # @private - class ::Hpricot::XMLDecl - # @see Haml::HTML::Node#to_haml - def to_haml(tabs, options) - "#{tabulate(tabs)}!!! XML\n" - end - end - - # @see Hpricot - # @private - class ::Hpricot::CData - # @see Haml::HTML::Node#to_haml - def to_haml(tabs, options) - content = parse_text_with_interpolation( - erb_to_interpolation(self.content, options), tabs + 1) - "#{tabulate(tabs)}:cdata\n#{content}" - end - end - - # @see Hpricot - # @private - class ::Hpricot::DocType - # @see Haml::HTML::Node#to_haml - def to_haml(tabs, options) - attrs = public_id.nil? ? ["", "", ""] : - public_id.scan(/DTD\s+([^\s]+)\s*([^\s]*)\s*([^\s]*)\s*\/\//)[0] - raise Haml::SyntaxError.new("Invalid doctype") if attrs == nil - - type, version, strictness = attrs.map { |a| a.downcase } - if type == "html" - version = "" - strictness = "strict" if strictness == "" - end - - if version == "1.0" || version.empty? - version = nil - end - - if strictness == 'transitional' || strictness.empty? - strictness = nil - end - - version = " #{version.capitalize}" if version - strictness = " #{strictness.capitalize}" if strictness - - "#{tabulate(tabs)}!!!#{version}#{strictness}\n" - end - end - - # @see Hpricot - # @private - class ::Hpricot::Comment - # @see Haml::HTML::Node#to_haml - def to_haml(tabs, options) - content = self.content - if content =~ /\A(\[[^\]]+\])>(.*) 1 # Multiline script block - # Normalize the indentation so that the last line is the base - indent_str = lines.last[/^[ \t]*/] - indent_re = /^[ \t]{0,#{indent_str.count(" ") + 8 * indent_str.count("\t")}}/ - lines.map! {|s| s.gsub!(indent_re, '')} - - # Add an extra " " to make it indented relative to "= " - lines[1..-1].each {|s| s.gsub!(/^/, " ")} - - # Add | at the end, properly aligned - length = lines.map {|s| s.size}.max + 1 - lines.map! {|s| "%#{-length}s|" % s} - - if next_sibling && next_sibling.is_a?(Hpricot::Elem) && next_sibling.name == "haml:loud" && - next_sibling.inner_text.split("\n").reject {|s| s.strip.empty?}.size > 1 - lines << "-#" - end - end - return lines.map {|s| output + s + "\n"}.join - when "silent" - return CGI.unescapeHTML(inner_text).split("\n").map do |line| - next "" if line.strip.empty? - "#{output}- #{line.strip}\n" - end.join - when "block" - return render_children("", tabs, options) - end - end - - if self.next && self.next.text? && self.next.content =~ /\A[^\s]/ - if self.previous.nil? || self.previous.text? && - (self.previous.content =~ /[^\s]\Z/ || - self.previous.content =~ /\A\s*\Z/ && self.previous.previous.nil?) - nuke_outer_whitespace = true - else - output << "= succeed #{self.next.content.slice!(/\A[^\s]+/).dump} do\n" - tabs += 1 - output << tabulate(tabs) - end - end - - output << "%#{name}" unless name == 'div' && - (static_id?(options) || - static_classname?(options) && - attr_hash['class'].split(' ').any?(&method(:haml_css_attr?))) - - if attr_hash - if static_id?(options) - output << "##{attr_hash['id']}" - remove_attribute('id') - end - if static_classname?(options) - leftover = attr_hash['class'].split(' ').reject do |c| - next unless haml_css_attr?(c) - output << ".#{c}" - end - remove_attribute('class') - set_attribute('class', leftover.join(' ')) unless leftover.empty? - end - output << haml_attributes(options) if attr_hash.length > 0 - end - - output << ">" if nuke_outer_whitespace - output << "/" if empty? && !etag - - if children && children.size == 1 - child = children.first - if child.is_a?(::Hpricot::Text) - if !child.to_s.include?("\n") - text = child.to_haml(tabs + 1, options) - return output + " " + text.lstrip.gsub(/^\\/, '') unless text.chomp.include?("\n") - return output + "\n" + text - elsif ["pre", "textarea"].include?(name) || - (name == "code" && parent.is_a?(::Hpricot::Elem) && parent.name == "pre") - return output + "\n#{tabulate(tabs + 1)}:preserve\n" + - innerText.gsub(/^/, tabulate(tabs + 2)) - end - elsif child.is_a?(::Hpricot::Elem) && child.name == "haml:loud" - return output + child.to_haml(tabs + 1, options).lstrip - end - end - - render_children(output + "\n", tabs, options) - end - - private - - def render_children(so_far, tabs, options) - (self.children || []).inject(so_far) do |output, child| - output + child.to_haml(tabs + 1, options) - end - end - - def dynamic_attributes - @dynamic_attributes ||= begin - Haml::Util.map_hash(attr_hash) do |name, value| - next if value.empty? - full_match = nil - ruby_value = value.gsub(%r{\s*(.+?)\s*}) do - full_match = $`.empty? && $'.empty? - CGI.unescapeHTML(full_match ? $1: "\#{#{$1}}") - end - next if ruby_value == value - [name, full_match ? ruby_value : %("#{ruby_value}")] - end - end - end - - def to_haml_filter(filter, tabs, options) - content = - if children.first.is_a?(::Hpricot::CData) - children.first.content - else - CGI.unescapeHTML(self.innerText) - end - - content = erb_to_interpolation(content, options) - content.gsub!(/\A\s*\n(\s*)/, '\1') - original_indent = content[/\A(\s*)/, 1] - if content.split("\n").all? {|l| l.strip.empty? || l =~ /^#{original_indent}/} - content.gsub!(/^#{original_indent}/, tabulate(tabs + 1)) - end - - "#{tabulate(tabs)}:#{filter}\n#{content}" - end - - def static_attribute?(name, options) - attr_hash[name] && !dynamic_attribute?(name, options) - end - - def dynamic_attribute?(name, options) - options[:erb] and dynamic_attributes.key?(name) - end - - def static_id?(options) - static_attribute?('id', options) && haml_css_attr?(attr_hash['id']) - end - - def static_classname?(options) - static_attribute?('class', options) - end - - def haml_css_attr?(attr) - attr =~ /^[-:\w]+$/ - end - - # Returns a string representation of an attributes hash - # that's prettier than that produced by Hash#inspect - def haml_attributes(options) - attrs = attr_hash.sort.map do |name, value| - value = dynamic_attribute?(name, options) ? dynamic_attributes[name] : value.inspect - name = name.index(/\W/) ? name.inspect : ":#{name}" - "#{name} => #{value}" - end - "{#{attrs.join(', ')}}" - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/html/erb.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/html/erb.rb deleted file mode 100644 index f1cff89fe2..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/html/erb.rb +++ /dev/null @@ -1,141 +0,0 @@ -require 'cgi' -require 'erubis' -require 'ruby_parser' - -module Haml - class HTML - # A class for converting ERB code into a format that's easier - # for the {Haml::HTML} Hpricot-based parser to understand. - # - # Uses [Erubis](http://www.kuwata-lab.com/erubis)'s extensible parsing powers - # to parse the ERB in a reliable way, - # and [ruby_parser](http://parsetree.rubyforge.org/)'s Ruby knowledge - # to figure out whether a given chunk of Ruby code starts a block or not. - # - # The ERB tags are converted to HTML tags in the following way. - # `<% ... %>` is converted into ` ... `. - # `<%= ... %>` is converted into ` ... `. - # Finally, if either of these opens a Ruby block, - # ` ... ` will wrap the entire contents of the block - - # that is, everything that should be indented beneath the previous silent or loud tag. - class ERB < Erubis::Basic::Engine - # Compiles an ERB template into a HTML document containing `haml:` tags. - # - # @param template [String] The ERB template - # @return [String] The output document - # @see Haml::HTML::ERB - def self.compile(template) - new(template).src - end - - # `html2haml` doesn't support HTML-escaped expressions. - def escaped_expr(code) - raise Haml::Error.new("html2haml doesn't support escaped expressions.") - end - - # The ERB-to-Hamlized-HTML conversion has no preamble. - def add_preamble(src); end - - # The ERB-to-Hamlized-HTML conversion has no postamble. - def add_postamble(src); end - - # Concatenates the text onto the source buffer. - # - # @param src [String] The source buffer - # @param text [String] The raw text to add to the buffer - def add_text(src, text) - src << text - end - - # Concatenates a silent Ruby statement onto the source buffer. - # This uses the `` tag, - # and may close and/or open a Ruby block with the `` tag. - # - # In particular, a block is closed if this statement is some form of `end`, - # opened if it's a block opener like `do`, `if`, or `begin`, - # and both closed and opened if it's a mid-block keyword - # like `else` or `when`. - # - # @param src [String] The source buffer - # @param code [String] The Ruby statement to add to the buffer - def add_stmt(src, code) - src << '' if block_closer?(code) || mid_block?(code) - src << '' << h(code) << '' unless code.strip == "end" - src << '' if block_opener?(code) || mid_block?(code) - end - - # Concatenates a Ruby expression that's printed to the document - # onto the source buffer. - # This uses the `` tag, - # and may open a Ruby block with the `` tag. - # An expression never closes a block. - # - # @param src [String] The source buffer - # @param code [String] The Ruby expression to add to the buffer - def add_expr_literal(src, code) - src << '' << h(code) << '' - src << '' if block_opener?(code) - end - - # `html2haml` doesn't support debugging expressions. - def add_expr_debug(src, code) - raise Haml::Error.new("html2haml doesn't support debugging expressions.") - end - - private - - # HTML-escaped some text (in practice, always Ruby code). - # A utility method. - # - # @param text [String] The text to escape - # @return [String] The escaped text - def h(text) - CGI.escapeHTML(text) - end - - # Returns whether the code is valid Ruby code on its own. - # - # @param code [String] Ruby code to check - # @return [Boolean] - def valid_ruby?(code) - RubyParser.new.parse(code) - rescue Racc::ParseError => e - false - end - - # Checks if a string of Ruby code opens a block. - # This could either be something like `foo do |a|` - # or a keyword that requires a matching `end` - # like `if`, `begin`, or `case`. - # - # @param code [String] Ruby code to check - # @return [Boolean] - def block_opener?(code) - valid_ruby?(code + "\nend") || - valid_ruby?(code + "\nwhen foo\nend") - end - - # Checks if a string of Ruby code closes a block. - # This is always `end` followed optionally by some method calls. - # - # @param code [String] Ruby code to check - # @return [Boolean] - def block_closer?(code) - valid_ruby?("begin\n" + code) - end - - # Checks if a string of Ruby code comes in the middle of a block. - # This could be a keyword like `else`, `rescue`, or `when`, - # or even `end` with a method call that takes a block. - # - # @param code [String] Ruby code to check - # @return [Boolean] - def mid_block?(code) - return if valid_ruby?(code) - valid_ruby?("if foo\n#{code}\nend") || # else, elsif - valid_ruby?("begin\n#{code}\nend") || # rescue, ensure - valid_ruby?("case foo\n#{code}\nend") # when - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/parser.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/parser.rb deleted file mode 100644 index cf57c94060..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/parser.rb +++ /dev/null @@ -1,711 +0,0 @@ -require 'strscan' -require 'haml/shared' - -module Haml - module Parser - include Haml::Util - - # Designates an XHTML/XML element. - ELEMENT = ?% - - # Designates a `
    ` element with the given class. - DIV_CLASS = ?. - - # Designates a `
    ` element with the given id. - DIV_ID = ?# - - # Designates an XHTML/XML comment. - COMMENT = ?/ - - # Designates an XHTML doctype or script that is never HTML-escaped. - DOCTYPE = ?! - - # Designates script, the result of which is output. - SCRIPT = ?= - - # Designates script that is always HTML-escaped. - SANITIZE = ?& - - # Designates script, the result of which is flattened and output. - FLAT_SCRIPT = ?~ - - # Designates script which is run but not output. - SILENT_SCRIPT = ?- - - # When following SILENT_SCRIPT, designates a comment that is not output. - SILENT_COMMENT = ?# - - # Designates a non-parsed line. - ESCAPE = ?\\ - - # Designates a block of filtered text. - FILTER = ?: - - # Designates a non-parsed line. Not actually a character. - PLAIN_TEXT = -1 - - # Keeps track of the ASCII values of the characters that begin a - # specially-interpreted line. - SPECIAL_CHARACTERS = [ - ELEMENT, - DIV_CLASS, - DIV_ID, - COMMENT, - DOCTYPE, - SCRIPT, - SANITIZE, - FLAT_SCRIPT, - SILENT_SCRIPT, - ESCAPE, - FILTER - ] - - # The value of the character that designates that a line is part - # of a multiline string. - MULTILINE_CHAR_VALUE = ?| - - MID_BLOCK_KEYWORDS = %w[else elsif rescue ensure end when] - START_BLOCK_KEYWORDS = %w[if begin case] - # Try to parse assignments to block starters as best as possible - START_BLOCK_KEYWORD_REGEX = /(?:\w+(?:,\s*\w+)*\s*=\s*)?(#{START_BLOCK_KEYWORDS.join('|')})/ - BLOCK_KEYWORD_REGEX = /^-\s*(?:(#{MID_BLOCK_KEYWORDS.join('|')})|#{START_BLOCK_KEYWORD_REGEX.source})\b/ - - # The Regex that matches a Doctype command. - DOCTYPE_REGEX = /(\d(?:\.\d)?)?[\s]*([a-z]*)\s*([^ ]+)?/i - - # The Regex that matches a literal string or symbol value - LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?![\\#]|\2).|\\.)*\2/ - - private - - # @private - class Line < Struct.new(:text, :unstripped, :full, :index, :compiler, :eod) - alias_method :eod?, :eod - - # @private - def tabs - line = self - @tabs ||= compiler.instance_eval do - break 0 if line.text.empty? || !(whitespace = line.full[/^\s+/]) - - if @indentation.nil? - @indentation = whitespace - - if @indentation.include?(?\s) && @indentation.include?(?\t) - raise SyntaxError.new("Indentation can't use both tabs and spaces.", line.index) - end - - @flat_spaces = @indentation * (@template_tabs+1) if flat? - break 1 - end - - tabs = whitespace.length / @indentation.length - break tabs if whitespace == @indentation * tabs - break @template_tabs + 1 if flat? && whitespace =~ /^#{@flat_spaces}/ - - raise SyntaxError.new(< 1 - raise SyntaxError.new("The line was indented #{@next_line.tabs - @line.tabs} levels deeper than the previous line.", @next_line.index) - end - - @line = @next_line - end - - # Close all the open tags - close until @parent.type == :root - @root - end - - # Processes and deals with lowering indentation. - def process_indent(line) - return unless line.tabs <= @template_tabs && @template_tabs > 0 - - to_close = @template_tabs - line.tabs - to_close.times {|i| close unless to_close - 1 - i == 0 && mid_block_keyword?(line.text)} - end - - # Processes a single line of Haml. - # - # This method doesn't return anything; it simply processes the line and - # adds the appropriate code to `@precompiled`. - def process_line(text, index) - @index = index + 1 - - case text[0] - when DIV_CLASS; push div(text) - when DIV_ID - return push plain(text) if text[1] == ?{ - push div(text) - when ELEMENT; push tag(text) - when COMMENT; push comment(text[1..-1].strip) - when SANITIZE - return push plain(text[3..-1].strip, :escape_html) if text[1..2] == "==" - return push script(text[2..-1].strip, :escape_html) if text[1] == SCRIPT - return push flat_script(text[2..-1].strip, :escape_html) if text[1] == FLAT_SCRIPT - return push plain(text[1..-1].strip, :escape_html) if text[1] == ?\s - push plain(text) - when SCRIPT - return push plain(text[2..-1].strip) if text[1] == SCRIPT - push script(text[1..-1]) - when FLAT_SCRIPT; push flat_script(text[1..-1]) - when SILENT_SCRIPT; push silent_script(text) - when FILTER; push filter(text[1..-1].downcase) - when DOCTYPE - return push doctype(text) if text[0...3] == '!!!' - return push plain(text[3..-1].strip, !:escape_html) if text[1..2] == "==" - return push script(text[2..-1].strip, !:escape_html) if text[1] == SCRIPT - return push flat_script(text[2..-1].strip, !:escape_html) if text[1] == FLAT_SCRIPT - return push plain(text[1..-1].strip, !:escape_html) if text[1] == ?\s - push plain(text) - when ESCAPE; push plain(text[1..-1]) - else; push plain(text) - end - end - - def block_keyword(text) - return unless keyword = text.scan(BLOCK_KEYWORD_REGEX)[0] - keyword[0] || keyword[1] - end - - def mid_block_keyword?(text) - MID_BLOCK_KEYWORDS.include?(block_keyword(text)) - end - - def push(node) - @parent.children << node - node.parent = @parent - end - - def plain(text, escape_html = nil) - if block_opened? - raise SyntaxError.new("Illegal nesting: nesting within plain text is illegal.", @next_line.index) - end - - unless contains_interpolation?(text) - return ParseNode.new(:plain, @index, :text => text) - end - - escape_html = @options[:escape_html] if escape_html.nil? - script(unescape_interpolation(text, escape_html), !:escape_html) - end - - def script(text, escape_html = nil, preserve = false) - raise SyntaxError.new("There's no Ruby code for = to evaluate.") if text.empty? - text = handle_ruby_multiline(text) - escape_html = @options[:escape_html] if escape_html.nil? - - ParseNode.new(:script, @index, :text => text, :escape_html => escape_html, - :preserve => preserve) - end - - def flat_script(text, escape_html = nil) - raise SyntaxError.new("There's no Ruby code for ~ to evaluate.") if text.empty? - script(text, escape_html, :preserve) - end - - def silent_script(text) - return haml_comment(text[2..-1]) if text[1] == SILENT_COMMENT - - raise SyntaxError.new(< text[1..-1], :keyword => keyword) - end - - def haml_comment(text) - @haml_comment = block_opened? - ParseNode.new(:haml_comment, @index, :text => text) - end - - def tag(line) - tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace, - nuke_inner_whitespace, action, value, last_line = parse_tag(line) - - preserve_tag = @options[:preserve].include?(tag_name) - nuke_inner_whitespace ||= preserve_tag - preserve_tag = false if @options[:ugly] - escape_html = (action == '&' || (action != '!' && @options[:escape_html])) - - case action - when '/'; self_closing = true - when '~'; parse = preserve_script = true - when '=' - parse = true - if value[0] == ?= - value = unescape_interpolation(value[1..-1].strip, escape_html) - escape_html = false - end - when '&', '!' - if value[0] == ?= || value[0] == ?~ - parse = true - preserve_script = (value[0] == ?~) - if value[1] == ?= - value = unescape_interpolation(value[2..-1].strip, escape_html) - escape_html = false - else - value = value[1..-1].strip - end - elsif contains_interpolation?(value) - value = unescape_interpolation(value, escape_html) - parse = true - escape_html = false - end - else - if contains_interpolation?(value) - value = unescape_interpolation(value, escape_html) - parse = true - escape_html = false - end - end - - attributes = Parser.parse_class_and_id(attributes) - attributes_list = [] - - if attributes_hashes[:new] - static_attributes, attributes_hash = attributes_hashes[:new] - Buffer.merge_attrs(attributes, static_attributes) if static_attributes - attributes_list << attributes_hash - end - - if attributes_hashes[:old] - static_attributes = parse_static_hash(attributes_hashes[:old]) - Buffer.merge_attrs(attributes, static_attributes) if static_attributes - attributes_list << attributes_hashes[:old] unless static_attributes || @options[:suppress_eval] - end - - attributes_list.compact! - - raise SyntaxError.new("Illegal nesting: nesting within a self-closing tag is illegal.", @next_line.index) if block_opened? && self_closing - raise SyntaxError.new("There's no Ruby code for #{action} to evaluate.", last_line - 1) if parse && value.empty? - raise SyntaxError.new("Self-closing tags can't have content.", last_line - 1) if self_closing && !value.empty? - - if block_opened? && !value.empty? && !is_ruby_multiline?(value) - raise SyntaxError.new("Illegal nesting: content can't be both given on the same line as %#{tag_name} and nested within it.", @next_line.index) - end - - self_closing ||= !!(!block_opened? && value.empty? && @options[:autoclose].any? {|t| t === tag_name}) - value = nil if value.empty? && (block_opened? || self_closing) - value = handle_ruby_multiline(value) if parse - - ParseNode.new(:tag, @index, :name => tag_name, :attributes => attributes, - :attributes_hashes => attributes_list, :self_closing => self_closing, - :nuke_inner_whitespace => nuke_inner_whitespace, - :nuke_outer_whitespace => nuke_outer_whitespace, :object_ref => object_ref, - :escape_html => escape_html, :preserve_tag => preserve_tag, - :preserve_script => preserve_script, :parse => parse, :value => value) - end - - # Renders a line that creates an XHTML tag and has an implicit div because of - # `.` or `#`. - def div(line) - tag('%div' + line) - end - - # Renders an XHTML comment. - def comment(line) - conditional, line = balance(line, ?[, ?]) if line[0] == ?[ - line.strip! - conditional << ">" if conditional - - if block_opened? && !line.empty? - raise SyntaxError.new('Illegal nesting: nesting within a tag that already has content is illegal.', @next_line.index) - end - - ParseNode.new(:comment, @index, :conditional => conditional, :text => line) - end - - # Renders an XHTML doctype or XML shebang. - def doctype(line) - raise SyntaxError.new("Illegal nesting: nesting within a header command is illegal.", @next_line.index) if block_opened? - version, type, encoding = line[3..-1].strip.downcase.scan(DOCTYPE_REGEX)[0] - ParseNode.new(:doctype, @index, :version => version, :type => type, :encoding => encoding) - end - - def filter(name) - raise Error.new("Invalid filter name \":#{name}\".") unless name =~ /^\w+$/ - - @filter_buffer = String.new - - if filter_opened? - @flat = true - # If we don't know the indentation by now, it'll be set in Line#tabs - @flat_spaces = @indentation * (@template_tabs+1) if @indentation - end - - ParseNode.new(:filter, @index, :name => name, :text => @filter_buffer) - end - - def close - node, @parent = @parent, @parent.parent - @template_tabs -= 1 - send("close_#{node.type}", node) if respond_to?("close_#{node.type}", :include_private) - end - - def close_filter(_) - @flat = false - @flat_spaces = nil - @filter_buffer = nil - end - - def close_haml_comment(_) - @haml_comment = false - end - - def close_silent_script(node) - # Post-process case statements to normalize the nesting of "when" clauses - return unless node.value[:keyword] == "case" - return unless first = node.children.first - return unless first.type == :silent_script && first.value[:keyword] == "when" - return if first.children.empty? - # If the case node has a "when" child with children, it's the - # only child. Then we want to put everything nested beneath it - # beneath the case itself (just like "if"). - node.children = [first, *first.children] - first.children = [] - end - - # This is a class method so it can be accessed from {Haml::Helpers}. - # - # Iterates through the classes and ids supplied through `.` - # and `#` syntax, and returns a hash with them as attributes, - # that can then be merged with another attributes hash. - def self.parse_class_and_id(list) - attributes = {} - list.scan(/([#.])([-:_a-zA-Z0-9]+)/) do |type, property| - case type - when '.' - if attributes['class'] - attributes['class'] += " " - else - attributes['class'] = "" - end - attributes['class'] += property - when '#'; attributes['id'] = property - end - end - attributes - end - - def parse_static_hash(text) - attributes = {} - scanner = StringScanner.new(text) - scanner.scan(/\s+/) - until scanner.eos? - return unless key = scanner.scan(LITERAL_VALUE_REGEX) - return unless scanner.scan(/\s*=>\s*/) - return unless value = scanner.scan(LITERAL_VALUE_REGEX) - return unless scanner.scan(/\s*(?:,|$)\s*/) - attributes[eval(key).to_s] = eval(value).to_s - end - attributes - end - - # Parses a line into tag_name, attributes, attributes_hash, object_ref, action, value - def parse_tag(line) - raise SyntaxError.new("Invalid tag: \"#{line}\".") unless match = line.scan(/%([-:\w]+)([-:\w\.\#]*)(.*)/)[0] - - tag_name, attributes, rest = match - raise SyntaxError.new("Illegal element: classes and ids must have values.") if attributes =~ /[\.#](\.|#|\z)/ - - new_attributes_hash = old_attributes_hash = last_line = nil - object_ref = "nil" - attributes_hashes = {} - while rest - case rest[0] - when ?{ - break if old_attributes_hash - old_attributes_hash, rest, last_line = parse_old_attributes(rest) - attributes_hashes[:old] = old_attributes_hash - when ?( - break if new_attributes_hash - new_attributes_hash, rest, last_line = parse_new_attributes(rest) - attributes_hashes[:new] = new_attributes_hash - when ?[ - break unless object_ref == "nil" - object_ref, rest = balance(rest, ?[, ?]) - else; break - end - end - - if rest - nuke_whitespace, action, value = rest.scan(/(<>|><|[><])?([=\/\~&!])?(.*)?/)[0] - nuke_whitespace ||= '' - nuke_outer_whitespace = nuke_whitespace.include? '>' - nuke_inner_whitespace = nuke_whitespace.include? '<' - end - - value = value.to_s.strip - [tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace, - nuke_inner_whitespace, action, value, last_line || @index] - end - - def parse_old_attributes(line) - line = line.dup - last_line = @index - - begin - attributes_hash, rest = balance(line, ?{, ?}) - rescue SyntaxError => e - if line.strip[-1] == ?, && e.message == "Unbalanced brackets." - line << "\n" << @next_line.text - last_line += 1 - next_line - retry - end - - raise e - end - - attributes_hash = attributes_hash[1...-1] if attributes_hash - return attributes_hash, rest, last_line - end - - def parse_new_attributes(line) - line = line.dup - scanner = StringScanner.new(line) - last_line = @index - attributes = {} - - scanner.scan(/\(\s*/) - loop do - name, value = parse_new_attribute(scanner) - break if name.nil? - - if name == false - text = (Haml::Shared.balance(line, ?(, ?)) || [line]).first - raise Haml::SyntaxError.new("Invalid attribute list: #{text.inspect}.", last_line - 1) - end - attributes[name] = value - scanner.scan(/\s*/) - - if scanner.eos? - line << " " << @next_line.text - last_line += 1 - next_line - scanner.scan(/\s*/) - end - end - - static_attributes = {} - dynamic_attributes = "{" - attributes.each do |name, (type, val)| - if type == :static - static_attributes[name] = val - else - dynamic_attributes << inspect_obj(name) << " => " << val << "," - end - end - dynamic_attributes << "}" - dynamic_attributes = nil if dynamic_attributes == "{}" - - return [static_attributes, dynamic_attributes], scanner.rest, last_line - end - - def parse_new_attribute(scanner) - unless name = scanner.scan(/[-:\w]+/) - return if scanner.scan(/\)/) - return false - end - - scanner.scan(/\s*/) - return name, [:static, true] unless scanner.scan(/=/) #/end - - scanner.scan(/\s*/) - unless quote = scanner.scan(/["']/) - return false unless var = scanner.scan(/(@@?|\$)?\w+/) - return name, [:dynamic, var] - end - - re = /((?:\\.|\#(?!\{)|[^#{quote}\\#])*)(#{quote}|#\{)/ - content = [] - loop do - return false unless scanner.scan(re) - content << [:str, scanner[1].gsub(/\\(.)/, '\1')] - break if scanner[2] == quote - content << [:ruby, balance(scanner, ?{, ?}, 1).first[0...-1]] - end - - return name, [:static, content.first[1]] if content.size == 1 - return name, [:dynamic, - '"' + content.map {|(t, v)| t == :str ? inspect_obj(v)[1...-1] : "\#{#{v}}"}.join + '"'] - end - - def raw_next_line - text = @template.shift - return unless text - - index = @template_index - @template_index += 1 - - return text, index - end - - def next_line - text, index = raw_next_line - return unless text - - # :eod is a special end-of-document marker - line = - if text == :eod - Line.new '-#', '-#', '-#', index, self, true - else - Line.new text.strip, text.lstrip.chomp, text, index, self, false - end - - # `flat?' here is a little outdated, - # so we have to manually check if either the previous or current line - # closes the flat block, as well as whether a new block is opened. - @line.tabs if @line - unless (flat? && !closes_flat?(line) && !closes_flat?(@line)) || - (@line && @line.text[0] == ?: && line.full =~ %r[^#{@line.full[/^\s+/]}\s]) - return next_line if line.text.empty? - - handle_multiline(line) - end - - @next_line = line - end - - def closes_flat?(line) - line && !line.text.empty? && line.full !~ /^#{@flat_spaces}/ - end - - def un_next_line(line) - @template.unshift line - @template_index -= 1 - end - - def handle_multiline(line) - return unless is_multiline?(line.text) - line.text.slice!(-1) - while new_line = raw_next_line.first - break if new_line == :eod - next if new_line.strip.empty? - break unless is_multiline?(new_line.strip) - line.text << new_line.strip[0...-1] - end - un_next_line new_line - end - - # Checks whether or not `line` is in a multiline sequence. - def is_multiline?(text) - text && text.length > 1 && text[-1] == MULTILINE_CHAR_VALUE && text[-2] == ?\s - end - - def handle_ruby_multiline(text) - text = text.rstrip - return text unless is_ruby_multiline?(text) - un_next_line @next_line.full - begin - new_line = raw_next_line.first - break if new_line == :eod - next if new_line.strip.empty? - text << " " << new_line.strip - end while is_ruby_multiline?(new_line.strip) - next_line - text - end - - def is_ruby_multiline?(text) - text && text.length > 1 && text[-1] == ?, && text[-2] != ?? && text[-3..-2] != "?\\" - end - - def contains_interpolation?(str) - str.include?('#{') - end - - def unescape_interpolation(str, escape_html = nil) - res = '' - rest = Haml::Shared.handle_interpolation str.dump do |scan| - escapes = (scan[2].size - 1) / 2 - res << scan.matched[0...-3 - escapes] - if escapes % 2 == 1 - res << '#{' - else - content = eval('"' + balance(scan, ?{, ?}, 1)[0][0...-1] + '"') - content = "Haml::Helpers.html_escape((#{content}))" if escape_html - res << '#{' + content + "}"# Use eval to get rid of string escapes - end - end - res + rest - end - - def balance(*args) - res = Haml::Shared.balance(*args) - return res if res - raise SyntaxError.new("Unbalanced brackets.") - end - - def block_opened? - @next_line.tabs > @line.tabs - end - - # Same semantics as block_opened?, except that block_opened? uses Line#tabs, - # which doesn't interact well with filter lines - def filter_opened? - @next_line.full =~ (@indentation ? /^#{@indentation * @template_tabs}/ : /^\s/) - end - - def flat? - @flat - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/railtie.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/railtie.rb deleted file mode 100644 index 818cc352ea..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/railtie.rb +++ /dev/null @@ -1,19 +0,0 @@ -if Haml::Util.ap_geq_3? && !Haml::Util.ap_geq?("3.0.0.beta4") - raise < Object}] - attr_accessor :options - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/template/patch.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/template/patch.rb deleted file mode 100644 index 0c219c4e3c..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/template/patch.rb +++ /dev/null @@ -1,58 +0,0 @@ -# This file makes Haml work with Rails -# by monkeypatching the core template-compilation methods. -# This is necessary for versions <= 2.0.1 because the template handler API -# wasn't sufficiently powerful to deal with caching and so forth. - -# This module refers to the ActionView module that's part of Ruby on Rails. -# Haml can be used as an alternate templating engine for it, -# and includes several modifications to make it more Haml-friendly. -# The documentation can be found -# here[http://rubyonrails.org/api/classes/ActionView/Base.html]. -module ActionView - class Base - def delegate_template_exists_with_haml(template_path) - template_exists?(template_path, :haml) && [:haml] - end - alias_method :delegate_template_exists_without_haml, :delegate_template_exists? - alias_method :delegate_template_exists?, :delegate_template_exists_with_haml - - def compile_template_with_haml(extension, template, file_name, local_assigns) - return compile_haml(template, file_name, local_assigns) if extension.to_s == "haml" - compile_template_without_haml(extension, template, file_name, local_assigns) - end - alias_method :compile_template_without_haml, :compile_template - alias_method :compile_template, :compile_template_with_haml - - def compile_haml(template, file_name, local_assigns) - render_symbol = assign_method_name(:haml, template, file_name) - locals = local_assigns.keys - - @@template_args[render_symbol] ||= {} - locals_keys = @@template_args[render_symbol].keys | locals - @@template_args[render_symbol] = Haml::Util.to_hash(locals_keys.map {|k| [k, true]}) - - options = Haml::Template.options.dup - options[:filename] = file_name || 'compiled-template' - - begin - Haml::Engine.new(template, options).def_method(CompiledTemplates, render_symbol, *locals_keys) - rescue Exception => e - if logger - logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}" - logger.debug "Backtrace: #{e.backtrace.join("\n")}" - end - - base_path = if defined?(extract_base_path_from) - # Rails 2.0.x - extract_base_path_from(file_name) || view_paths.first - else - # Rails <=1.2.6 - @base_path - end - raise ActionView::TemplateError.new(base_path, file_name || template, @assigns, template, e) - end - - @@compile_time[render_symbol] = Time.now - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/template/plugin.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/template/plugin.rb deleted file mode 100644 index 734cab8ba5..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/template/plugin.rb +++ /dev/null @@ -1,123 +0,0 @@ -# This file makes Haml work with Rails -# using the > 2.0.1 template handler API. - -module Haml - # In Rails 3.1+, template handlers don't inherit from anything. In <= 3.0, they do. - # To avoid messy logic figuring this out, we just inherit from whatever the ERB handler does. - class Plugin < Haml::Util.av_template_class(:Handlers)::ERB.superclass - if ((defined?(ActionView::TemplateHandlers) && - defined?(ActionView::TemplateHandlers::Compilable)) || - (defined?(ActionView::Template) && - defined?(ActionView::Template::Handlers) && - defined?(ActionView::Template::Handlers::Compilable))) && - # In Rails 3.1+, we don't need to include Compilable. - Haml::Util.av_template_class(:Handlers)::ERB.include?( - Haml::Util.av_template_class(:Handlers)::Compilable) - include Haml::Util.av_template_class(:Handlers)::Compilable - end - - def handles_encoding?; true; end - - def compile(template) - options = Haml::Template.options.dup - - # template is a template object in Rails >=2.1.0, - # a source string previously - if template.respond_to? :source - # Template has a generic identifier in Rails >=3.0.0 - options[:filename] = template.respond_to?(:identifier) ? template.identifier : template.filename - source = template.source - else - source = template - end - - Haml::Engine.new(source, options).send(:precompiled_with_ambles, []) - end - - # In Rails 3.1+, #call takes the place of #compile - def self.call(template) - new.compile(template) - end - - def cache_fragment(block, name = {}, options = nil) - @view.fragment_for(block, name, options) do - eval("_hamlout.buffer", block.binding) - end - end - end - - # Rails 3.0 prints a deprecation warning when block helpers - # return strings that go unused. - # We want to print the same deprecation warning, - # so we have to compile in a method call to check for it. - # - # I don't like having this in the compilation pipeline, - # and I'd like to get rid of it once Rails 3.1 is well-established. - if defined?(ActionView::OutputBuffer) && - Haml::Util.has?(:instance_method, ActionView::OutputBuffer, :append_if_string=) - module Compiler - def compile_silent_script_with_haml_block_deprecation(&block) - unless block && !@node.value[:keyword] && - @node.value[:text] =~ ActionView::Template::Handlers::Erubis::BLOCK_EXPR - return compile_silent_script_without_haml_block_deprecation(&block) - end - - @node.value[:text] = "_hamlout.append_if_string= #{@node.value[:text]}" - compile_silent_script_without_haml_block_deprecation(&block) - end - alias_method :compile_silent_script_without_haml_block_deprecation, :compile_silent_script - alias_method :compile_silent_script, :compile_silent_script_with_haml_block_deprecation - end - - class Buffer - def append_if_string=(value) - if value.is_a?(String) && !value.is_a?(ActionView::NonConcattingString) - ActiveSupport::Deprecation.warn("- style block helpers are deprecated. Please use =", caller) - buffer << value - end - end - end - end -end - -if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler - ActionView::Template -else - ActionView::Base -end.register_template_handler(:haml, Haml::Plugin) - -# In Rails 2.0.2, ActionView::TemplateError took arguments -# that we can't fill in from the Haml::Plugin context. -# Thus, we've got to monkeypatch ActionView::Base to catch the error. -if defined?(ActionView::TemplateError) && - ActionView::TemplateError.instance_method(:initialize).arity == 5 - class ActionView::Base - def compile_template(handler, template, file_name, local_assigns) - render_symbol = assign_method_name(handler, template, file_name) - - # Move begin up two lines so it captures compilation exceptions. - begin - render_source = create_template_source(handler, template, render_symbol, local_assigns.keys) - line_offset = @@template_args[render_symbol].size + handler.line_offset - - file_name = 'compiled-template' if file_name.blank? - CompiledTemplates.module_eval(render_source, file_name, -line_offset) - rescue Exception => e # errors from template code - if logger - logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}" - logger.debug "Function body: #{render_source}" - logger.debug "Backtrace: #{e.backtrace.join("\n")}" - end - - # There's no way to tell Haml about the filename, - # so we've got to insert it ourselves. - e.backtrace[0].gsub!('(haml)', file_name) if e.is_a?(Haml::Error) - - raise ActionView::TemplateError.new(extract_base_path_from(file_name) || view_paths.first, file_name || template, @assigns, template, e) - end - - @@compile_time[render_symbol] = Time.now - # logger.debug "Compiled template #{file_name || template}\n ==> #{render_symbol}" if logger - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/util.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/util.rb deleted file mode 100644 index 7e7b887146..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/util.rb +++ /dev/null @@ -1,842 +0,0 @@ -require 'erb' -require 'set' -require 'enumerator' -require 'stringio' -require 'strscan' -require 'rbconfig' - -require 'haml/root' - -module Haml - # A module containing various useful functions. - module Util - extend self - - # An array of ints representing the Ruby version number. - # @api public - RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i} - - # The Ruby engine we're running under. Defaults to `"ruby"` - # if the top-level constant is undefined. - # @api public - RUBY_ENGINE = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby" - - # Returns the path of a file relative to the Haml root directory. - # - # @param file [String] The filename relative to the Haml root - # @return [String] The filename relative to the the working directory - def scope(file) - File.join(Haml::ROOT_DIR, file) - end - - # Converts an array of `[key, value]` pairs to a hash. - # - # @example - # to_hash([[:foo, "bar"], [:baz, "bang"]]) - # #=> {:foo => "bar", :baz => "bang"} - # @param arr [Array<(Object, Object)>] An array of pairs - # @return [Hash] A hash - def to_hash(arr) - Hash[arr.compact] - end - - # Maps the keys in a hash according to a block. - # - # @example - # map_keys({:foo => "bar", :baz => "bang"}) {|k| k.to_s} - # #=> {"foo" => "bar", "baz" => "bang"} - # @param hash [Hash] The hash to map - # @yield [key] A block in which the keys are transformed - # @yieldparam key [Object] The key that should be mapped - # @yieldreturn [Object] The new value for the key - # @return [Hash] The mapped hash - # @see #map_vals - # @see #map_hash - def map_keys(hash) - to_hash(hash.map {|k, v| [yield(k), v]}) - end - - # Maps the values in a hash according to a block. - # - # @example - # map_values({:foo => "bar", :baz => "bang"}) {|v| v.to_sym} - # #=> {:foo => :bar, :baz => :bang} - # @param hash [Hash] The hash to map - # @yield [value] A block in which the values are transformed - # @yieldparam value [Object] The value that should be mapped - # @yieldreturn [Object] The new value for the value - # @return [Hash] The mapped hash - # @see #map_keys - # @see #map_hash - def map_vals(hash) - to_hash(hash.map {|k, v| [k, yield(v)]}) - end - - # Maps the key-value pairs of a hash according to a block. - # - # @example - # map_hash({:foo => "bar", :baz => "bang"}) {|k, v| [k.to_s, v.to_sym]} - # #=> {"foo" => :bar, "baz" => :bang} - # @param hash [Hash] The hash to map - # @yield [key, value] A block in which the key-value pairs are transformed - # @yieldparam [key] The hash key - # @yieldparam [value] The hash value - # @yieldreturn [(Object, Object)] The new value for the `[key, value]` pair - # @return [Hash] The mapped hash - # @see #map_keys - # @see #map_vals - def map_hash(hash, &block) - to_hash(hash.map(&block)) - end - - # Computes the powerset of the given array. - # This is the set of all subsets of the array. - # - # @example - # powerset([1, 2, 3]) #=> - # Set[Set[], Set[1], Set[2], Set[3], Set[1, 2], Set[2, 3], Set[1, 3], Set[1, 2, 3]] - # @param arr [Enumerable] - # @return [Set] The subsets of `arr` - def powerset(arr) - arr.inject([Set.new].to_set) do |powerset, el| - new_powerset = Set.new - powerset.each do |subset| - new_powerset << subset - new_powerset << subset + [el] - end - new_powerset - end - end - - # Restricts a number to falling within a given range. - # Returns the number if it falls within the range, - # or the closest value in the range if it doesn't. - # - # @param value [Numeric] - # @param range [Range] - # @return [Numeric] - def restrict(value, range) - [[value, range.first].max, range.last].min - end - - # Concatenates all strings that are adjacent in an array, - # while leaving other elements as they are. - # - # @example - # merge_adjacent_strings([1, "foo", "bar", 2, "baz"]) - # #=> [1, "foobar", 2, "baz"] - # @param arr [Array] - # @return [Array] The enumerable with strings merged - def merge_adjacent_strings(arr) - # Optimize for the common case of one element - return arr if arr.size < 2 - arr.inject([]) do |a, e| - if e.is_a?(String) - if a.last.is_a?(String) - a.last << e - else - a << e.dup - end - else - a << e - end - a - end - end - - # Intersperses a value in an enumerable, as would be done with `Array#join` - # but without concatenating the array together afterwards. - # - # @param enum [Enumerable] - # @param val - # @return [Array] - def intersperse(enum, val) - enum.inject([]) {|a, e| a << e << val}[0...-1] - end - - # Substitutes a sub-array of one array with another sub-array. - # - # @param ary [Array] The array in which to make the substitution - # @param from [Array] The sequence of elements to replace with `to` - # @param to [Array] The sequence of elements to replace `from` with - def substitute(ary, from, to) - res = ary.dup - i = 0 - while i < res.size - if res[i...i+from.size] == from - res[i...i+from.size] = to - end - i += 1 - end - res - end - - # Destructively strips whitespace from the beginning and end - # of the first and last elements, respectively, - # in the array (if those elements are strings). - # - # @param arr [Array] - # @return [Array] `arr` - def strip_string_array(arr) - arr.first.lstrip! if arr.first.is_a?(String) - arr.last.rstrip! if arr.last.is_a?(String) - arr - end - - # Return an array of all possible paths through the given arrays. - # - # @param arrs [Array] - # @return [Array] - # - # @example - # paths([[1, 2], [3, 4], [5]]) #=> - # # [[1, 3, 5], - # # [2, 3, 5], - # # [1, 4, 5], - # # [2, 4, 5]] - def paths(arrs) - arrs.inject([[]]) do |paths, arr| - flatten(arr.map {|e| paths.map {|path| path + [e]}}, 1) - end - end - - # Computes a single longest common subsequence for `x` and `y`. - # If there are more than one longest common subsequences, - # the one returned is that which starts first in `x`. - # - # @param x [Array] - # @param y [Array] - # @yield [a, b] An optional block to use in place of a check for equality - # between elements of `x` and `y`. - # @yieldreturn [Object, nil] If the two values register as equal, - # this will return the value to use in the LCS array. - # @return [Array] The LCS - def lcs(x, y, &block) - x = [nil, *x] - y = [nil, *y] - block ||= proc {|a, b| a == b && a} - lcs_backtrace(lcs_table(x, y, &block), x, y, x.size-1, y.size-1, &block) - end - - # Returns information about the caller of the previous method. - # - # @param entry [String] An entry in the `#caller` list, or a similarly formatted string - # @return [[String, Fixnum, (String, nil)]] An array containing the filename, line, and method name of the caller. - # The method name may be nil - def caller_info(entry = caller[1]) - info = entry.scan(/^(.*?):(-?.*?)(?::.*`(.+)')?$/).first - info[1] = info[1].to_i - # This is added by Rubinius to designate a block, but we don't care about it. - info[2].sub!(/ \{\}\Z/, '') if info[2] - info - end - - # Returns whether one version string represents a more recent version than another. - # - # @param v1 [String] A version string. - # @param v2 [String] Another version string. - # @return [Boolean] - def version_gt(v1, v2) - # Construct an array to make sure the shorter version is padded with nil - Array.new([v1.length, v2.length].max).zip(v1.split("."), v2.split(".")) do |_, p1, p2| - p1 ||= "0" - p2 ||= "0" - release1 = p1 =~ /^[0-9]+$/ - release2 = p2 =~ /^[0-9]+$/ - if release1 && release2 - # Integer comparison if both are full releases - p1, p2 = p1.to_i, p2.to_i - next if p1 == p2 - return p1 > p2 - elsif !release1 && !release2 - # String comparison if both are prereleases - next if p1 == p2 - return p1 > p2 - else - # If only one is a release, that one is newer - return release1 - end - end - end - - # Returns whether one version string represents the same or a more - # recent version than another. - # - # @param v1 [String] A version string. - # @param v2 [String] Another version string. - # @return [Boolean] - def version_geq(v1, v2) - version_gt(v1, v2) || !version_gt(v2, v1) - end - - # A wrapper for `Marshal.dump` that calls `#_before_dump` on the object - # before dumping it, `#_after_dump` afterwards. - # It also calls `#_around_dump` and passes it a block in which the object is dumped. - # - # If any of these methods are undefined, they are not called. - # - # @param obj [Object] The object to dump. - # @return [String] The dumped data. - def dump(obj) - obj._before_dump if obj.respond_to?(:_before_dump) - return Marshal.dump(obj) unless obj.respond_to?(:_around_dump) - res = nil - obj._around_dump {res = Marshal.dump(obj)} - res - ensure - obj._after_dump if obj.respond_to?(:_after_dump) - end - - # A wrapper for `Marshal.load` that calls `#_after_load` on the object - # after loading it, if it's defined. - # - # @param data [String] The data to load. - # @return [Object] The loaded object. - def load(data) - obj = Marshal.load(data) - obj._after_load if obj.respond_to?(:_after_load) - obj - end - - # Throws a NotImplementedError for an abstract method. - # - # @param obj [Object] `self` - # @raise [NotImplementedError] - def abstract(obj) - raise NotImplementedError.new("#{obj.class} must implement ##{caller_info[2]}") - end - - # Silence all output to STDERR within a block. - # - # @yield A block in which no output will be printed to STDERR - def silence_warnings - the_real_stderr, $stderr = $stderr, StringIO.new - yield - ensure - $stderr = the_real_stderr - end - - @@silence_warnings = false - # Silences all Haml warnings within a block. - # - # @yield A block in which no Haml warnings will be printed - def silence_haml_warnings - old_silence_warnings = @@silence_warnings - @@silence_warnings = true - yield - ensure - @@silence_warnings = old_silence_warnings - end - - # The same as `Kernel#warn`, but is silenced by \{#silence\_haml\_warnings}. - # - # @param msg [String] - def haml_warn(msg) - return if @@silence_warnings - warn(msg) - end - - # Try loading Sass. If the `sass` gem isn't installed, - # print a warning and load from the vendored gem. - # - # @return [Boolean] True if Sass was successfully loaded from the `sass` gem, - # false otherwise. - def try_sass - return true if defined?(::SASS_BEGUN_TO_LOAD) - begin - require 'sass/version' - loaded = Sass.respond_to?(:version) && Sass.version[:major] && - Sass.version[:minor] && ((Sass.version[:major] > 3 && Sass.version[:minor] > 1) || - ((Sass.version[:major] == 3 && Sass.version[:minor] == 1) && - (Sass.version[:prerelease] || Sass.version[:name] != "Bleeding Edge"))) - rescue LoadError => e - loaded = false - end - - unless loaded - haml_warn(<= 3 - return false unless defined?(ActionPack) && defined?(ActionPack::VERSION) && - defined?(ActionPack::VERSION::STRING) - - version_geq(ActionPack::VERSION::STRING, version) - end - - # Returns an ActionView::Template* class. - # In pre-3.0 versions of Rails, most of these classes - # were of the form `ActionView::TemplateFoo`, - # while afterwards they were of the form `ActionView;:Template::Foo`. - # - # @param name [#to_s] The name of the class to get. - # For example, `:Error` will return `ActionView::TemplateError` - # or `ActionView::Template::Error`. - def av_template_class(name) - return ActionView.const_get("Template#{name}") if ActionView.const_defined?("Template#{name}") - return ActionView::Template.const_get(name.to_s) - end - - ## Rails XSS Safety - - # Whether or not ActionView's XSS protection is available and enabled, - # as is the default for Rails 3.0+, and optional for version 2.3.5+. - # Overridden in haml/template.rb if this is the case. - # - # @return [Boolean] - def rails_xss_safe? - false - end - - # Returns the given text, marked as being HTML-safe. - # With older versions of the Rails XSS-safety mechanism, - # this destructively modifies the HTML-safety of `text`. - # - # @param text [String, nil] - # @return [String, nil] `text`, marked as HTML-safe - def html_safe(text) - return unless text - return text.html_safe if defined?(ActiveSupport::SafeBuffer) - text.html_safe! - end - - # Assert that a given object (usually a String) is HTML safe - # according to Rails' XSS handling, if it's loaded. - # - # @param text [Object] - def assert_html_safe!(text) - return unless rails_xss_safe? && text && !text.to_s.html_safe? - raise Haml::Error.new("Expected #{text.inspect} to be HTML-safe.") - end - - # The class for the Rails SafeBuffer XSS protection class. - # This varies depending on Rails version. - # - # @return [Class] - def rails_safe_buffer_class - # It's important that we check ActiveSupport first, - # because in Rails 2.3.6 ActionView::SafeBuffer exists - # but is a deprecated proxy object. - return ActiveSupport::SafeBuffer if defined?(ActiveSupport::SafeBuffer) - return ActionView::SafeBuffer - end - - ## Cross-OS Compatibility - - # Whether or not this is running on Windows. - # - # @return [Boolean] - def windows? - RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i - end - - # Whether or not this is running on IronRuby. - # - # @return [Boolean] - def ironruby? - RUBY_ENGINE == "ironruby" - end - - ## Cross-Ruby-Version Compatibility - - # Whether or not this is running under Ruby 1.8 or lower. - # - # Note that IronRuby counts as Ruby 1.8, - # because it doesn't support the Ruby 1.9 encoding API. - # - # @return [Boolean] - def ruby1_8? - # IronRuby says its version is 1.9, but doesn't support any of the encoding APIs. - # We have to fall back to 1.8 behavior. - ironruby? || (Haml::Util::RUBY_VERSION[0] == 1 && Haml::Util::RUBY_VERSION[1] < 9) - end - - # Whether or not this is running under Ruby 1.8.6 or lower. - # Note that lower versions are not officially supported. - # - # @return [Boolean] - def ruby1_8_6? - ruby1_8? && Haml::Util::RUBY_VERSION[2] < 7 - end - - # Checks that the encoding of a string is valid in Ruby 1.9 - # and cleans up potential encoding gotchas like the UTF-8 BOM. - # If it's not, yields an error string describing the invalid character - # and the line on which it occurrs. - # - # @param str [String] The string of which to check the encoding - # @yield [msg] A block in which an encoding error can be raised. - # Only yields if there is an encoding error - # @yieldparam msg [String] The error message to be raised - # @return [String] `str`, potentially with encoding gotchas like BOMs removed - def check_encoding(str) - if ruby1_8? - return str.gsub(/\A\xEF\xBB\xBF/, '') # Get rid of the UTF-8 BOM - elsif str.valid_encoding? - # Get rid of the Unicode BOM if possible - if str.encoding.name =~ /^UTF-(8|16|32)(BE|LE)?$/ - return str.gsub(Regexp.new("\\A\uFEFF".encode(str.encoding.name)), '') - else - return str - end - end - - encoding = str.encoding - newlines = Regexp.new("\r\n|\r|\n".encode(encoding).force_encoding("binary")) - str.force_encoding("binary").split(newlines).each_with_index do |line, i| - begin - line.encode(encoding) - rescue Encoding::UndefinedConversionError => e - yield < true - # - # Method collections like `Class#instance_methods` - # return strings in Ruby 1.8 and symbols in Ruby 1.9 and on, - # so this handles checking for them in a compatible way. - # - # @param attr [#to_s] The (singular) name of the method-collection method - # (e.g. `:instance_methods`, `:private_methods`) - # @param klass [Module] The class to check the methods of which to check - # @param method [String, Symbol] The name of the method do check for - # @return [Boolean] Whether or not the given collection has the given method - def has?(attr, klass, method) - klass.send("#{attr}s").include?(ruby1_8? ? method.to_s : method.to_sym) - end - - # A version of `Enumerable#enum_with_index` that works in Ruby 1.8 and 1.9. - # - # @param enum [Enumerable] The enumerable to get the enumerator for - # @return [Enumerator] The with-index enumerator - def enum_with_index(enum) - ruby1_8? ? enum.enum_with_index : enum.each_with_index - end - - # A version of `Enumerable#enum_cons` that works in Ruby 1.8 and 1.9. - # - # @param enum [Enumerable] The enumerable to get the enumerator for - # @param n [Fixnum] The size of each cons - # @return [Enumerator] The consed enumerator - def enum_cons(enum, n) - ruby1_8? ? enum.enum_cons(n) : enum.each_cons(n) - end - - # A version of `Enumerable#enum_slice` that works in Ruby 1.8 and 1.9. - # - # @param enum [Enumerable] The enumerable to get the enumerator for - # @param n [Fixnum] The size of each slice - # @return [Enumerator] The consed enumerator - def enum_slice(enum, n) - ruby1_8? ? enum.enum_slice(n) : enum.each_slice(n) - end - - # Returns the ASCII code of the given character. - # - # @param c [String] All characters but the first are ignored. - # @return [Fixnum] The ASCII code of `c`. - def ord(c) - ruby1_8? ? c[0] : c.ord - end - - # Flattens the first `n` nested arrays in a cross-version manner. - # - # @param arr [Array] The array to flatten - # @param n [Fixnum] The number of levels to flatten - # @return [Array] The flattened array - def flatten(arr, n) - return arr.flatten(n) unless ruby1_8_6? - return arr if n == 0 - arr.inject([]) {|res, e| e.is_a?(Array) ? res.concat(flatten(e, n - 1)) : res << e} - end - - # Returns the hash code for a set in a cross-version manner. - # Aggravatingly, this is order-dependent in Ruby 1.8.6. - # - # @param set [Set] - # @return [Fixnum] The order-independent hashcode of `set` - def set_hash(set) - return set.hash unless ruby1_8_6? - set.map {|e| e.hash}.uniq.sort.hash - end - - # Tests the hash-equality of two sets in a cross-version manner. - # Aggravatingly, this is order-dependent in Ruby 1.8.6. - # - # @param set1 [Set] - # @param set2 [Set] - # @return [Boolean] Whether or not the sets are hashcode equal - def set_eql?(set1, set2) - return set1.eql?(set2) unless ruby1_8_6? - set1.to_a.uniq.sort_by {|e| e.hash}.eql?(set2.to_a.uniq.sort_by {|e| e.hash}) - end - - # Like `Object#inspect`, but preserves non-ASCII characters rather than escaping them under Ruby 1.9.2. - # This is necessary so that the precompiled Haml template can be `#encode`d into `@options[:encoding]` - # before being evaluated. - # - # @param obj {Object} - # @return {String} - def inspect_obj(obj) - return obj.inspect unless version_geq(::RUBY_VERSION, "1.9.2") - return ':' + inspect_obj(obj.to_s) if obj.is_a?(Symbol) - return obj.inspect unless obj.is_a?(String) - '"' + obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]} + '"' - end - - ## Static Method Stuff - - # The context in which the ERB for \{#def\_static\_method} will be run. - class StaticConditionalContext - # @param set [#include?] The set of variables that are defined for this context. - def initialize(set) - @set = set - end - - # Checks whether or not a variable is defined for this context. - # - # @param name [Symbol] The name of the variable - # @return [Boolean] - def method_missing(name, *args, &block) - super unless args.empty? && block.nil? - @set.include?(name) - end - end - - # This is used for methods in {Haml::Buffer} that need to be very fast, - # and take a lot of boolean parameters - # that are known at compile-time. - # Instead of passing the parameters in normally, - # a separate method is defined for every possible combination of those parameters; - # these are then called using \{#static\_method\_name}. - # - # To define a static method, an ERB template for the method is provided. - # All conditionals based on the static parameters - # are done as embedded Ruby within this template. - # For example: - # - # def_static_method(Foo, :my_static_method, [:foo, :bar], :baz, :bang, < - # return foo + bar - # <% elsif baz || bang %> - # return foo - bar - # <% else %> - # return 17 - # <% end %> - # RUBY - # - # \{#static\_method\_name} can be used to call static methods. - # - # @overload def_static_method(klass, name, args, *vars, erb) - # @param klass [Module] The class on which to define the static method - # @param name [#to_s] The (base) name of the static method - # @param args [Array] The names of the arguments to the defined methods - # (**not** to the ERB template) - # @param vars [Array] The names of the static boolean variables - # to be made available to the ERB template - # @param erb [String] The template for the method code - def def_static_method(klass, name, args, *vars) - erb = vars.pop - info = caller_info - powerset(vars).each do |set| - context = StaticConditionalContext.new(set).instance_eval {binding} - klass.class_eval(<] The static variable assignment - # @return [String] The real name of the static method - def static_method_name(name, *vars) - "#{name}_#{vars.map {|v| !!v}.join('_')}" - end - - private - - # Calculates the memoization table for the Least Common Subsequence algorithm. - # Algorithm from [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Computing_the_length_of_the_LCS) - def lcs_table(x, y) - c = Array.new(x.size) {[]} - x.size.times {|i| c[i][0] = 0} - y.size.times {|j| c[0][j] = 0} - (1...x.size).each do |i| - (1...y.size).each do |j| - c[i][j] = - if yield x[i], y[j] - c[i-1][j-1] + 1 - else - [c[i][j-1], c[i-1][j]].max - end - end - end - return c - end - - # Computes a single longest common subsequence for arrays x and y. - # Algorithm from [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Reading_out_an_LCS) - def lcs_backtrace(c, x, y, i, j, &block) - return [] if i == 0 || j == 0 - if v = yield(x[i], y[j]) - return lcs_backtrace(c, x, y, i-1, j-1, &block) << v - end - - return lcs_backtrace(c, x, y, i, j-1, &block) if c[i][j-1] > c[i-1][j] - return lcs_backtrace(c, x, y, i-1, j, &block) - end - - # Parses a magic comment at the beginning of a Haml file. - # The parsing rules are basically the same as Ruby's. - # - # @return [(Boolean, String or nil)] - # Whether the document begins with a UTF-8 BOM, - # and the declared encoding of the document (or nil if none is declared) - def parse_haml_magic_comment(str) - scanner = StringScanner.new(str.dup.force_encoding("BINARY")) - bom = scanner.scan(/\xEF\xBB\xBF/n) - return bom unless scanner.scan(/-\s*#\s*/n) - if coding = try_parse_haml_emacs_magic_comment(scanner) - return bom, coding - end - - return bom unless scanner.scan(/.*?coding[=:]\s*([\w-]+)/in) - return bom, scanner[1] - end - - def try_parse_haml_emacs_magic_comment(scanner) - pos = scanner.pos - return unless scanner.scan(/.*?-\*-\s*/n) - # From Ruby's parse.y - return unless scanner.scan(/([^\s'":;]+)\s*:\s*("(?:\\.|[^"])*"|[^"\s;]+?)[\s;]*-\*-/n) - name, val = scanner[1], scanner[2] - return unless name =~ /(en)?coding/in - val = $1 if val =~ /^"(.*)"$/n - return val - ensure - scanner.pos = pos - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/version.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/version.rb deleted file mode 100644 index bd58c23b9b..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/haml/version.rb +++ /dev/null @@ -1,109 +0,0 @@ -require 'haml/util' - -module Haml - # Handles Haml version-reporting. - # Haml not only reports the standard three version numbers, - # but its Git revision hash as well, - # if it was installed from Git. - module Version - include Haml::Util - - # Returns a hash representing the version of Haml. - # The `:major`, `:minor`, and `:teeny` keys have their respective numbers as Fixnums. - # The `:name` key has the name of the version. - # The `:string` key contains a human-readable string representation of the version. - # The `:number` key is the major, minor, and teeny keys separated by periods. - # If Haml is checked out from Git, the `:rev` key will have the revision hash. - # For example: - # - # { - # :string => "2.1.0.9616393", - # :rev => "9616393b8924ef36639c7e82aa88a51a24d16949", - # :number => "2.1.0", - # :major => 2, :minor => 1, :teeny => 0 - # } - # - # If a prerelease version of Haml is being used, - # the `:string` and `:number` fields will reflect the full version - # (e.g. `"2.2.beta.1"`), and the `:teeny` field will be `-1`. - # A `:prerelease` key will contain the name of the prerelease (e.g. `"beta"`), - # and a `:prerelease_number` key will contain the rerelease number. - # For example: - # - # { - # :string => "3.0.beta.1", - # :number => "3.0.beta.1", - # :major => 3, :minor => 0, :teeny => -1, - # :prerelease => "beta", - # :prerelease_number => 1 - # } - # - # @return [{Symbol => String/Fixnum}] The version hash - def version - return @@version if defined?(@@version) - - numbers = File.read(scope('VERSION')).strip.split('.'). - map {|n| n =~ /^[0-9]+$/ ? n.to_i : n} - name = File.read(scope('VERSION_NAME')).strip - @@version = { - :major => numbers[0], - :minor => numbers[1], - :teeny => numbers[2], - :name => name - } - - if numbers[3].is_a?(String) - @@version[:teeny] = -1 - @@version[:prerelease] = numbers[3] - @@version[:prerelease_number] = numbers[4] - end - - @@version[:number] = numbers.join('.') - @@version[:string] = @@version[:number].dup - - if rev = revision_number - @@version[:rev] = rev - unless rev[0] == ?( - @@version[:string] << "." << rev[0...7] - end - end - - @@version[:string] << " (#{name})" - @@version - end - - private - - def revision_number - if File.exists?(scope('REVISION')) - rev = File.read(scope('REVISION')).strip - return rev unless rev =~ /^([a-f0-9]+|\(.*\))$/ || rev == '(unknown)' - end - - return unless File.exists?(scope('.git/HEAD')) - rev = File.read(scope('.git/HEAD')).strip - return rev unless rev =~ /^ref: (.*)$/ - - ref_name = $1 - ref_file = scope(".git/#{ref_name}") - info_file = scope(".git/info/refs") - return File.read(ref_file).strip if File.exists?(ref_file) - return unless File.exists?(info_file) - File.open(info_file) do |f| - f.each do |l| - sha, ref = l.strip.split("\t", 2) - next unless ref == ref_name - return sha - end - end - return nil - end - end - - extend Haml::Version - - # A string representing the version of Haml. - # A more fine-grained representation is available from Haml.version. - # @api public - VERSION = version[:string] unless defined?(Haml::VERSION) -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass.rb deleted file mode 100644 index 87ba927ffc..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass.rb +++ /dev/null @@ -1,8 +0,0 @@ -dir = File.dirname(__FILE__) -$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir) - -require 'haml' - -unless Haml::Util.try_sass - load Haml::Util.scope('vendor/sass/lib/sass.rb') -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass/plugin.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass/plugin.rb deleted file mode 100644 index e5a3bc505e..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass/plugin.rb +++ /dev/null @@ -1,10 +0,0 @@ -dir = File.dirname(File.dirname(__FILE__)) -$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir) - -require 'haml' - -if Haml::Util.try_sass - load Sass::Util.scope('lib/sass/plugin.rb') -else - load Haml::Util.scope('vendor/sass/lib/sass/plugin.rb') -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass/rails2_shim.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass/rails2_shim.rb deleted file mode 100644 index ea61cc777a..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/lib/sass/rails2_shim.rb +++ /dev/null @@ -1,9 +0,0 @@ -Haml::Util.try_sass -Haml::Util.haml_warn(<=2.1.0 - base = ActionView::Base.new - base.finder.append_view_path(File.dirname(__FILE__)) - base -end - -def render(view, file) - view.render :file => file -end - -RBench.run(times) do - column :haml, :title => "Haml" - column :haml_ugly, :title => "Haml :ugly" - column :erb, :title => "ERB" - column :erubis, :title => "Erubis" - - template_name = 'standard' - directory = File.dirname(__FILE__) + '/haml' - haml_template = File.read("#{directory}/templates/#{template_name}.haml") - erb_template = File.read("#{directory}/erb/#{template_name}.erb") - - report "Cached" do - obj = Object.new - - Haml::Engine.new(haml_template).def_method(obj, :haml) - Haml::Engine.new(haml_template, :ugly => true).def_method(obj, :haml_ugly) - Erubis::Eruby.new(erb_template).def_method(obj, :erubis) - obj.instance_eval("def erb; #{ERB.new(erb_template, nil, '-').src}; end") - - haml { obj.haml } - haml_ugly { obj.haml_ugly } - erb { obj.erb } - erubis { obj.erubis } - end - - report "ActionView" do - @base = view - - @base.unmemoize_all - Haml::Template.options[:ugly] = false - # To cache the template - render @base, 'haml/templates/standard' - render @base, 'haml/erb/standard' - - haml { render @base, 'haml/templates/standard' } - erb { render @base, 'haml/erb/standard' } - - Haml::Template.options[:ugly] = true - render @base, 'haml/templates/standard_ugly' - haml_ugly { render @base, 'haml/templates/standard_ugly' } - end - - report "ActionView with deep partials" do - @base = view - - @base.unmemoize_all - Haml::Template.options[:ugly] = false - # To cache the template - render @base, 'haml/templates/action_view' - render @base, 'haml/erb/action_view' - - haml { render @base, 'haml/templates/action_view' } - erb { render @base, 'haml/erb/action_view' } - - Haml::Template.options[:ugly] = true - render @base, 'haml/templates/action_view_ugly' - haml_ugly { render @base, 'haml/templates/action_view_ugly' } - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/engine_test.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/engine_test.rb deleted file mode 100755 index 1235ce73a3..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/engine_test.rb +++ /dev/null @@ -1,1911 +0,0 @@ -#!/usr/bin/env ruby -# -*- coding: utf-8 -*- -require File.dirname(__FILE__) + '/../test_helper' - -class EngineTest < Test::Unit::TestCase - # A map of erroneous Haml documents to the error messages they should produce. - # The error messages may be arrays; - # if so, the second element should be the line number that should be reported for the error. - # If this isn't provided, the tests will assume the line number should be the last line of the document. - EXCEPTION_MAP = { - "!!!\n a" => "Illegal nesting: nesting within a header command is illegal.", - "a\n b" => "Illegal nesting: nesting within plain text is illegal.", - "/ a\n b" => "Illegal nesting: nesting within a tag that already has content is illegal.", - "% a" => 'Invalid tag: "% a".', - "%p a\n b" => "Illegal nesting: content can't be both given on the same line as %p and nested within it.", - "%p=" => "There's no Ruby code for = to evaluate.", - "%p~" => "There's no Ruby code for ~ to evaluate.", - "~" => "There's no Ruby code for ~ to evaluate.", - "=" => "There's no Ruby code for = to evaluate.", - "%p/\n a" => "Illegal nesting: nesting within a self-closing tag is illegal.", - ":a\n b" => ['Filter "a" is not defined.', 1], - ":a= b" => 'Invalid filter name ":a= b".', - "." => "Illegal element: classes and ids must have values.", - ".#" => "Illegal element: classes and ids must have values.", - ".{} a" => "Illegal element: classes and ids must have values.", - ".() a" => "Illegal element: classes and ids must have values.", - ".= a" => "Illegal element: classes and ids must have values.", - "%p..a" => "Illegal element: classes and ids must have values.", - "%a/ b" => "Self-closing tags can't have content.", - "%p{:a => 'b',\n:c => 'd'}/ e" => ["Self-closing tags can't have content.", 2], - "%p{:a => 'b',\n:c => 'd'}=" => ["There's no Ruby code for = to evaluate.", 2], - "%p.{:a => 'b',\n:c => 'd'} e" => ["Illegal element: classes and ids must have values.", 1], - "%p{:a => 'b',\n:c => 'd',\n:e => 'f'}\n%p/ a" => ["Self-closing tags can't have content.", 4], - "%p{:a => 'b',\n:c => 'd',\n:e => 'f'}\n- raise 'foo'" => ["foo", 4], - "%p{:a => 'b',\n:c => raise('foo'),\n:e => 'f'}" => ["foo", 2], - "%p{:a => 'b',\n:c => 'd',\n:e => raise('foo')}" => ["foo", 3], - " %p foo" => "Indenting at the beginning of the document is illegal.", - " %p foo" => "Indenting at the beginning of the document is illegal.", - "- end" => < ["Indenting at the beginning of the document is illegal.", 3], - "\n\n %p foo" => ["Indenting at the beginning of the document is illegal.", 3], - "%p\n foo\n foo" => ["Inconsistent indentation: 1 space was used for indentation, but the rest of the document was indented using 2 spaces.", 3], - "%p\n foo\n%p\n foo" => ["Inconsistent indentation: 1 space was used for indentation, but the rest of the document was indented using 2 spaces.", 4], - "%p\n\t\tfoo\n\tfoo" => ["Inconsistent indentation: 1 tab was used for indentation, but the rest of the document was indented using 2 tabs.", 3], - "%p\n foo\n foo" => ["Inconsistent indentation: 3 spaces were used for indentation, but the rest of the document was indented using 2 spaces.", 3], - "%p\n foo\n %p\n bar" => ["Inconsistent indentation: 3 spaces were used for indentation, but the rest of the document was indented using 2 spaces.", 4], - "%p\n :plain\n bar\n \t baz" => ['Inconsistent indentation: " \t " was used for indentation, but the rest of the document was indented using 2 spaces.', 4], - "%p\n foo\n%p\n bar" => ["The line was indented 2 levels deeper than the previous line.", 4], - "%p\n foo\n %p\n bar" => ["The line was indented 3 levels deeper than the previous line.", 4], - "%p\n \tfoo" => ["Indentation can't use both tabs and spaces.", 2], - "%p(" => "Invalid attribute list: \"(\".", - "%p(foo=\nbar)" => ["Invalid attribute list: \"(foo=\".", 1], - "%p(foo=)" => "Invalid attribute list: \"(foo=)\".", - "%p(foo 'bar')" => "Invalid attribute list: \"(foo 'bar')\".", - "%p(foo 'bar'\nbaz='bang')" => ["Invalid attribute list: \"(foo 'bar'\".", 1], - "%p(foo='bar'\nbaz 'bang'\nbip='bop')" => ["Invalid attribute list: \"(foo='bar' baz 'bang'\".", 2], - "%p{:foo => 'bar' :bar => 'baz'}" => :compile, - "%p{:foo => }" => :compile, - "%p{=> 'bar'}" => :compile, - "%p{:foo => 'bar}" => :compile, - "%p{'foo => 'bar'}" => :compile, - "%p{:foo => 'bar\"}" => :compile, - - # Regression tests - "- raise 'foo'\n\n\n\nbar" => ["foo", 1], - "= 'foo'\n-raise 'foo'" => ["foo", 2], - "\n\n\n- raise 'foo'" => ["foo", 4], - "%p foo |\n bar |\n baz |\nbop\n- raise 'foo'" => ["foo", 5], - "foo\n\n\n bar" => ["Illegal nesting: nesting within plain text is illegal.", 4], - "%p/\n\n bar" => ["Illegal nesting: nesting within a self-closing tag is illegal.", 3], - "%p foo\n\n bar" => ["Illegal nesting: content can't be both given on the same line as %p and nested within it.", 3], - "/ foo\n\n bar" => ["Illegal nesting: nesting within a tag that already has content is illegal.", 3], - "!!!\n\n bar" => ["Illegal nesting: nesting within a header command is illegal.", 3], - "foo\n:ruby\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6], - "foo\n:erb\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6], - "foo\n:plain\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6], - "foo\n:plain\n 1\n 2\n 3\n4\n- raise 'foo'" => ["foo", 7], - "foo\n:plain\n 1\n 2\n 3\#{''}\n- raise 'foo'" => ["foo", 6], - "foo\n:plain\n 1\n 2\n 3\#{''}\n4\n- raise 'foo'" => ["foo", 7], - "foo\n:plain\n 1\n 2\n \#{raise 'foo'}" => ["foo", 5], - "= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1], - "- case 1\n\n- when 1\n - raise 'foo'" => ["foo", 4], - } - - User = Struct.new('User', :id) - class CustomHamlClass < Struct.new(:id) - def haml_object_ref - "my_thing" - end - end - - def render(text, options = {}, &block) - scope = options.delete(:scope) || Object.new - locals = options.delete(:locals) || {} - engine(text, options).to_html(scope, locals, &block) - end - - def engine(text, options = {}) - unless options[:filename] - # use caller method name as fake filename. useful for debugging - i = -1 - caller[i+=1] =~ /`(.+?)'/ until $1 and $1.index('test_') == 0 - options[:filename] = "(#{$1})" - end - Haml::Engine.new(text, options) - end - - def setup - return if Haml::Util.ruby1_8? - @old_default_internal = Encoding.default_internal - Encoding.default_internal = nil - end - - def teardown - return if Haml::Util.ruby1_8? - Encoding.default_internal = @old_default_internal - end - - def test_empty_render - assert_equal "", render("") - end - - def test_flexible_tabulation - assert_equal("

    \n foo\n

    \n\n bar\n \n baz\n \n\n", - render("%p\n foo\n%q\n bar\n %a\n baz")) - assert_equal("

    \n foo\n

    \n\n bar\n \n baz\n \n\n", - render("%p\n\tfoo\n%q\n\tbar\n\t%a\n\t\tbaz")) - assert_equal("

    \n \t \t bar\n baz\n

    \n", - render("%p\n :plain\n \t \t bar\n baz")) - end - - def test_empty_render_should_remain_empty - assert_equal('', render('')) - end - - def test_attributes_should_render_correctly - assert_equal("
    ", render(".atlantis{:style => 'ugly'}").chomp) - end - - def test_css_id_as_attribute_should_be_appended_with_underscore - assert_equal("
    ", render("#my_id{:id => '1'}").chomp) - assert_equal("
    ", render("#my_id{:id => 1}").chomp) - end - - def test_ruby_code_should_work_inside_attributes - author = 'hcatlin' - assert_equal("

    foo

    ", render("%p{:class => 1+2} foo").chomp) - end - - def test_class_attr_with_array - assert_equal("

    foo

    \n", render("%p{:class => %w[a b]} foo")) # basic - assert_equal("

    foo

    \n", render("%p.css{:class => %w[a b]} foo")) # merge with css - assert_equal("

    foo

    \n", render("%p.css{:class => %w[css b]} foo")) # merge uniquely - assert_equal("

    foo

    \n", render("%p{:class => [%w[a b], %w[c d]]} foo")) # flatten - assert_equal("

    foo

    \n", render("%p{:class => [:a, :b] } foo")) # stringify - assert_equal("

    foo

    \n", render("%p{:class => [nil, false] } foo")) # strip falsey - assert_equal("

    foo

    \n", render("%p{:class => :a} foo")) # single stringify - assert_equal("

    foo

    \n", render("%p{:class => false} foo")) # single falsey - assert_equal("

    foo

    \n", render("%p(class='html'){:class => %w[a b]} foo")) # html attrs - end - - def test_id_attr_with_array - assert_equal("

    foo

    \n", render("%p{:id => %w[a b]} foo")) # basic - assert_equal("

    foo

    \n", render("%p#css{:id => %w[a b]} foo")) # merge with css - assert_equal("

    foo

    \n", render("%p{:id => [%w[a b], %w[c d]]} foo")) # flatten - assert_equal("

    foo

    \n", render("%p{:id => [:a, :b] } foo")) # stringify - assert_equal("

    foo

    \n", render("%p{:id => [nil, false] } foo")) # strip falsey - assert_equal("

    foo

    \n", render("%p{:id => :a} foo")) # single stringify - assert_equal("

    foo

    \n", render("%p{:id => false} foo")) # single falsey - assert_equal("

    foo

    \n", render("%p(id='html'){:id => %w[a b]} foo")) # html attrs - end - - def test_colon_in_class_attr - assert_equal("

    \n", render("%p.foo:bar/")) - end - - def test_colon_in_id_attr - assert_equal("

    \n", render("%p#foo:bar/")) - end - - def test_dynamic_attributes_with_no_content - assert_equal(< - -

    -HTML -%p - %a{:href => "http://" + "haml-lang.com"} -HAML - end - - def test_attributes_with_to_s - assert_equal(<

    -

    -

    -

    -HTML -%p#foo{:id => 1+1} -%p.foo{:class => 1+1} -%p{:blaz => 1+1} -%p{(1+1) => 1+1} -HAML - end - - def test_nil_should_render_empty_tag - assert_equal("
    ", - render(".no_attributes{:nil => nil}").chomp) - end - - def test_strings_should_get_stripped_inside_tags - assert_equal("
    This should have no spaces in front of it
    ", - render(".stripped This should have no spaces in front of it").chomp) - end - - def test_one_liner_should_be_one_line - assert_equal("

    Hello

    ", render('%p Hello').chomp) - end - - def test_one_liner_with_newline_shouldnt_be_one_line - assert_equal("

    \n foo\n bar\n

    ", render('%p= "foo\nbar"').chomp) - end - - def test_multi_render - engine = engine("%strong Hi there!") - assert_equal("Hi there!\n", engine.to_html) - assert_equal("Hi there!\n", engine.to_html) - assert_equal("Hi there!\n", engine.to_html) - end - - def test_interpolation - assert_equal("

    Hello World

    \n", render('%p Hello #{who}', :locals => {:who => 'World'})) - assert_equal("

    \n Hello World\n

    \n", render("%p\n Hello \#{who}", :locals => {:who => 'World'})) - end - - def test_interpolation_in_the_middle_of_a_string - assert_equal("\"title 'Title'. \"\n", - render("\"title '\#{\"Title\"}'. \"")) - end - - def test_interpolation_at_the_beginning_of_a_line - assert_equal("

    2

    \n", render('%p #{1 + 1}')) - assert_equal("

    \n 2\n

    \n", render("%p\n \#{1 + 1}")) - end - - def test_escaped_interpolation - assert_equal("

    Foo & Bar & Baz

    \n", render('%p& Foo #{"&"} Bar & Baz')) - end - - def test_nil_tag_value_should_render_as_empty - assert_equal("

    \n", render("%p= nil")) - end - - def test_tag_with_failed_if_should_render_as_empty - assert_equal("

    \n", render("%p= 'Hello' if false")) - end - - def test_static_attributes_with_empty_attr - assert_equal("\n", render("%img{:src => '/foo.png', :alt => ''}")) - end - - def test_dynamic_attributes_with_empty_attr - assert_equal("\n", render("%img{:width => nil, :src => '/foo.png', :alt => String.new}")) - end - - def test_attribute_hash_with_newlines - assert_equal("

    foop

    \n", render("%p{:a => 'b',\n :c => 'd'} foop")) - assert_equal("

    \n foop\n

    \n", render("%p{:a => 'b',\n :c => 'd'}\n foop")) - assert_equal("

    \n", render("%p{:a => 'b',\n :c => 'd'}/")) - assert_equal("

    \n", render("%p{:a => 'b',\n :c => 'd',\n :e => 'f'}")) - end - - def test_attr_hashes_not_modified - hash = {:color => 'red'} - assert_equal(< {:hash => hash})) -
    -
    -
    -HTML -%div{hash} -.special{hash} -%div{hash} -HAML - assert_equal(hash, {:color => 'red'}) - end - - def test_ugly_semi_prerendered_tags - assert_equal(< true)) -

    -

    foo

    -

    -

    foo

    -

    foo -bar

    -

    foo -bar

    -

    -foo -

    -HTML -%p{:a => 1 + 1} -%p{:a => 1 + 1} foo -%p{:a => 1 + 1}/ -%p{:a => 1 + 1}= "foo" -%p{:a => 1 + 1}= "foo\\nbar" -%p{:a => 1 + 1}~ "foo\\nbar" -%p{:a => 1 + 1} - foo -HAML - end - - def test_end_of_file_multiline - assert_equal("

    0

    \n

    1

    \n

    2

    \n", render("- for i in (0...3)\n %p= |\n i |")) - end - - def test_cr_newline - assert_equal("

    foo

    \n

    bar

    \n

    baz

    \n

    boom

    \n", render("%p foo\r%p bar\r\n%p baz\n\r%p boom")) - end - - def test_textareas - assert_equal("\n", - render('%textarea= "Foo\n bar\n baz"')) - - assert_equal("
    Foo
      bar
       baz
    \n", - render('%pre= "Foo\n bar\n baz"')) - - assert_equal("\n", - render("%textarea #{'a' * 100}")) - - assert_equal("

    \n \n

    \n", render(<Foo bar baz -HTML -%pre - %code - :preserve - Foo - bar - baz -HAML - end - - def test_boolean_attributes - assert_equal("

    \n", - render("%p{:foo => 'bar', :bar => true, :baz => 'true'}", :format => :html4)) - assert_equal("

    \n", - render("%p{:foo => 'bar', :bar => true, :baz => 'true'}", :format => :xhtml)) - - assert_equal("

    \n", - render("%p{:foo => 'bar', :bar => false, :baz => 'false'}", :format => :html4)) - assert_equal("

    \n", - render("%p{:foo => 'bar', :bar => false, :baz => 'false'}", :format => :xhtml)) - end - - def test_both_whitespace_nukes_work_together - assert_equal(<Foo - Bar

    -RESULT -%p - %q><= "Foo\\nBar" -SOURCE - end - - def test_nil_option - assert_equal("

    \n", render('%p{:foo => "bar"}', :attr_wrapper => nil)) - end - - # Regression tests - - def test_whitespace_nuke_with_both_newlines - assert_equal("

    foo

    \n", render('%p<= "\nfoo\n"')) - assert_equal(< -

    foo

    -

    -HTML -%p - %p<= "\\nfoo\\n" -HAML - end - - def test_whitespace_nuke_with_tags_and_else - assert_equal(< - foo - -HTML -%a - %b< - - if false - = "foo" - - else - foo -HAML - - assert_equal(< - - foo - - -HTML -%a - %b - - if false - = "foo" - - else - foo -HAML - end - - def test_outer_whitespace_nuke_with_empty_script - assert_equal(< - foo

    -HTML -%p - foo - = " " - %a> -HAML - end - - def test_both_case_indentation_work_with_deeply_nested_code - result = < - other - -RESULT - assert_equal(result, render(< true)) -= capture_haml do - foo -HAML - end - - def test_plain_equals_with_ugly - assert_equal("foo\nbar\n", render(< true)) -= "foo" -bar -HAML - end - - def test_inline_if - assert_equal(<One

    -

    -

    Three

    -HTML -- for name in ["One", "Two", "Three"] - %p= name unless name == "Two" -HAML - end - - def test_end_with_method_call - assert_equal(< - 2|3|4 - b-a-r -

    -HTML -%p - = [1, 2, 3].map do |i| - - i + 1 - - end.join("|") - = "bar".gsub(/./) do |s| - - s + "-" - - end.gsub(/-$/) do |s| - - '' -HAML - end - - def test_silent_end_with_stuff - assert_equal(<hi!

    -HTML -- if true - %p hi! -- end if "foo".gsub(/f/) do - - "z" -- end + "bar" -HAML - end - - def test_multiline_with_colon_after_filter - assert_equal(< "Bar", | - :b => "Baz" }[:a] | -HAML - assert_equal(< "Bar", | - :b => "Baz" }[:a] | -HAML - end - - def test_multiline_in_filter - assert_equal(< false)) -
    - bar -
    -HTML -#foo{:class => ''} - bar -HAML - end - - def test_escape_attrs_always - assert_equal(< :always)) -
    - bar -
    -HTML -#foo{:class => '"<>&"'} - bar -HAML - end - - def test_escape_html - html = < true)) -&= "&" -!= "&" -= "&" -HAML - - assert_equal(html, render(< true)) -&~ "&" -!~ "&" -~ "&" -HAML - - assert_equal(html, render(< true)) -& \#{"&"} -! \#{"&"} -\#{"&"} -HAML - - assert_equal(html, render(< true)) -&== \#{"&"} -!== \#{"&"} -== \#{"&"} -HAML - - tag_html = <&

    -

    &

    -

    &

    -HTML - - assert_equal(tag_html, render(< true)) -%p&= "&" -%p!= "&" -%p= "&" -HAML - - assert_equal(tag_html, render(< true)) -%p&~ "&" -%p!~ "&" -%p~ "&" -HAML - - assert_equal(tag_html, render(< true)) -%p& \#{"&"} -%p! \#{"&"} -%p \#{"&"} -HAML - - assert_equal(tag_html, render(< true)) -%p&== \#{"&"} -%p!== \#{"&"} -%p== \#{"&"} -HAML - end - - def test_new_attrs_with_hash - assert_equal("\n", render('%a(href="#")')) - end - - def test_javascript_filter_with_dynamic_interp_and_escape_html - assert_equal(< true)) - -HTML -:javascript - & < > \#{"&"} -HAML - end - - def test_html5_javascript_filter - assert_equal(< :html5)) - -HTML -:javascript - foo bar -HAML - end - - def test_html5_css_filter - assert_equal(< :html5)) - -HTML -:css - foo bar -HAML - end - - def test_erb_filter_with_multiline_expr - assert_equal(< -HAML - end - - def test_silent_script_with_hyphen_case - assert_equal("", render("- 'foo-case-bar-case'")) - end - - def test_silent_script_with_hyphen_end - assert_equal("", render("- 'foo-end-bar-end'")) - end - - def test_silent_script_with_hyphen_end_and_block - assert_equal(<foo-end

    -

    bar-end

    -HTML -- ("foo-end-bar-end".gsub(/\\w+-end/) do |s| - %p= s -- end; nil) -HAML - end - - def test_if_without_content_and_else - assert_equal(<Foo\n", - render('%a(href="#" rel="top") Foo')) - assert_equal("Foo\n", - render('%a(href="#") #{"Foo"}')) - - assert_equal("\n", render('%a(href="#\\"")')) - end - - def test_filter_with_newline_and_interp - assert_equal(< true)) -foo, -HTML -foo\#{"," if true} -HAML - end - - # HTML escaping tests - - def test_ampersand_equals_should_escape - assert_equal("

    \n foo & bar\n

    \n", render("%p\n &= 'foo & bar'", :escape_html => false)) - end - - def test_ampersand_equals_inline_should_escape - assert_equal("

    foo & bar

    \n", render("%p&= 'foo & bar'", :escape_html => false)) - end - - def test_ampersand_equals_should_escape_before_preserve - assert_equal("\n", render('%textarea&= "foo\nbar"', :escape_html => false)) - end - - def test_bang_equals_should_not_escape - assert_equal("

    \n foo & bar\n

    \n", render("%p\n != 'foo & bar'", :escape_html => true)) - end - - def test_bang_equals_inline_should_not_escape - assert_equal("

    foo & bar

    \n", render("%p!= 'foo & bar'", :escape_html => true)) - end - - def test_static_attributes_should_be_escaped - assert_equal("\n", - render("%img.atlantis{:style => 'ugly&stupid'}")) - assert_equal("
    foo
    \n", - render(".atlantis{:style => 'ugly&stupid'} foo")) - assert_equal("

    foo

    \n", - render("%p.atlantis{:style => 'ugly&stupid'}= 'foo'")) - assert_equal("

    \n", - render("%p.atlantis{:style => \"ugly\\nstupid\"}")) - end - - def test_dynamic_attributes_should_be_escaped - assert_equal("\n", - render("%img{:width => nil, :src => '&foo.png', :alt => String.new}")) - assert_equal("

    foo

    \n", - render("%p{:width => nil, :src => '&foo.png', :alt => String.new} foo")) - assert_equal("
    foo
    \n", - render("%div{:width => nil, :src => '&foo.png', :alt => String.new}= 'foo'")) - assert_equal("\n", - render("%img{:width => nil, :src => \"foo\\n.png\", :alt => String.new}")) - end - - def test_string_double_equals_should_be_esaped - assert_equal("

    4&<

    \n", render("%p== \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    4&<

    \n", render("%p== \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_escaped_inline_string_double_equals - assert_equal("

    4&<

    \n", render("%p&== \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    4&<

    \n", render("%p&== \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_unescaped_inline_string_double_equals - assert_equal("

    4&<

    \n", render("%p!== \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    4&<

    \n", render("%p!== \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_escaped_string_double_equals - assert_equal("

    \n 4&<\n

    \n", render("%p\n &== \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    \n 4&<\n

    \n", render("%p\n &== \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_unescaped_string_double_equals - assert_equal("

    \n 4&<\n

    \n", render("%p\n !== \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    \n 4&<\n

    \n", render("%p\n !== \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_string_interpolation_should_be_esaped - assert_equal("

    4&<

    \n", render("%p \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    4&<

    \n", render("%p \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_escaped_inline_string_interpolation - assert_equal("

    4&<

    \n", render("%p& \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    4&<

    \n", render("%p& \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_unescaped_inline_string_interpolation - assert_equal("

    4&<

    \n", render("%p! \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    4&<

    \n", render("%p! \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_escaped_string_interpolation - assert_equal("

    \n 4&<\n

    \n", render("%p\n & \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    \n 4&<\n

    \n", render("%p\n & \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_unescaped_string_interpolation - assert_equal("

    \n 4&<\n

    \n", render("%p\n ! \#{2+2}&\#{'<'}", :escape_html => true)) - assert_equal("

    \n 4&<\n

    \n", render("%p\n ! \#{2+2}&\#{'<'}", :escape_html => false)) - end - - def test_scripts_should_respect_escape_html_option - assert_equal("

    \n foo & bar\n

    \n", render("%p\n = 'foo & bar'", :escape_html => true)) - assert_equal("

    \n foo & bar\n

    \n", render("%p\n = 'foo & bar'", :escape_html => false)) - end - - def test_inline_scripts_should_respect_escape_html_option - assert_equal("

    foo & bar

    \n", render("%p= 'foo & bar'", :escape_html => true)) - assert_equal("

    foo & bar

    \n", render("%p= 'foo & bar'", :escape_html => false)) - end - - def test_script_ending_in_comment_should_render_when_html_is_escaped - assert_equal("foo&bar\n", render("= 'foo&bar' #comment", :escape_html => true)) - end - - def test_script_with_if_shouldnt_output - assert_equal(<foo

    -

    -HTML -%p= "foo" -%p= "bar" if false -HAML - end - - # Options tests - - def test_filename_and_line - begin - render("\n\n = abc", :filename => 'test', :line => 2) - rescue Exception => e - assert_kind_of Haml::SyntaxError, e - assert_match(/test:4/, e.backtrace.first) - end - - begin - render("\n\n= 123\n\n= nil[]", :filename => 'test', :line => 2) - rescue Exception => e - assert_kind_of NoMethodError, e - assert_match(/test:6/, e.backtrace.first) - end - end - - def test_stop_eval - assert_equal("", render("= 'Hello'", :suppress_eval => true)) - assert_equal("", render("- haml_concat 'foo'", :suppress_eval => true)) - assert_equal("
    \n", render("#foo{:yes => 'no'}/", :suppress_eval => true)) - assert_equal("
    \n", render("#foo{:yes => 'no', :call => a_function() }/", :suppress_eval => true)) - assert_equal("
    \n", render("%div[1]/", :suppress_eval => true)) - assert_equal("", render(":ruby\n Kernel.puts 'hello'", :suppress_eval => true)) - end - - def test_doctypes - assert_equal('', - render('!!!', :format => :html5).strip) - assert_equal('', render('!!! 5').strip) - assert_equal('', - render('!!! strict').strip) - assert_equal('', - render('!!! frameset').strip) - assert_equal('', - render('!!! mobile').strip) - assert_equal('', - render('!!! basic').strip) - assert_equal('', - render('!!! transitional').strip) - assert_equal('', - render('!!!').strip) - assert_equal('', - render('!!! strict', :format => :html4).strip) - assert_equal('', - render('!!! frameset', :format => :html4).strip) - assert_equal('', - render('!!! transitional', :format => :html4).strip) - assert_equal('', - render('!!!', :format => :html4).strip) - end - - def test_attr_wrapper - assert_equal("

    \n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*')) - assert_equal("

    \n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"')) - assert_equal("

    \n", render("%p{ :escaped => 'quo\\'te'}", :attr_wrapper => '"')) - assert_equal("

    \n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"')) - assert_equal("\n", render("!!! XML", :attr_wrapper => '"')) - end - - def test_autoclose_option - assert_equal("\n", render("%flaz{:foo => 'bar'}", :autoclose => ["flaz"])) - assert_equal(< [/^flaz/])) - - - -HTML -%flaz -%flaznicate -%flan -HAML - end - - def test_attrs_parsed_correctly - assert_equal("

    biddly='bar => baz'>

    \n", render("%p{'boom=>biddly' => 'bar => baz'}")) - assert_equal("

    \n", render("%p{'foo,bar' => 'baz, qux'}")) - assert_equal("

    \n", render("%p{ :escaped => \"quo\\nte\"}")) - assert_equal("

    \n", render("%p{ :escaped => \"quo\#{2 + 2}te\"}")) - end - - def test_correct_parsing_with_brackets - assert_equal("

    {tada} foo

    \n", render("%p{:class => 'foo'} {tada} foo")) - assert_equal("

    deep {nested { things }}

    \n", render("%p{:class => 'foo'} deep {nested { things }}")) - assert_equal("

    {a { d

    \n", render("%p{{:class => 'foo'}, :class => 'bar'} {a { d")) - assert_equal("

    a}

    \n", render("%p{:foo => 'bar'} a}")) - - foo = [] - foo[0] = Struct.new('Foo', :id).new - assert_equal("

    New User]

    \n", - render("%p[foo[0]] New User]", :locals => {:foo => foo})) - assert_equal("

    New User]

    \n", - render("%p[foo[0], :prefix] New User]", :locals => {:foo => foo})) - - foo[0].id = 1 - assert_equal("

    New User]

    \n", - render("%p[foo[0]] New User]", :locals => {:foo => foo})) - assert_equal("

    New User]

    \n", - render("%p[foo[0], :prefix] New User]", :locals => {:foo => foo})) - end - - def test_empty_attrs - assert_equal("

    empty

    \n", render("%p{ :attr => '' } empty")) - assert_equal("

    empty

    \n", render("%p{ :attr => x } empty", :locals => {:x => ''})) - end - - def test_nil_attrs - assert_equal("

    nil

    \n", render("%p{ :attr => nil } nil")) - assert_equal("

    nil

    \n", render("%p{ :attr => x } nil", :locals => {:x => nil})) - end - - def test_nil_id_with_syntactic_id - assert_equal("

    nil

    \n", render("%p#foo{:id => nil} nil")) - assert_equal("

    nil

    \n", render("%p#foo{{:id => 'bar'}, :id => nil} nil")) - assert_equal("

    nil

    \n", render("%p#foo{{:id => nil}, :id => 'bar'} nil")) - end - - def test_nil_class_with_syntactic_class - assert_equal("

    nil

    \n", render("%p.foo{:class => nil} nil")) - assert_equal("

    nil

    \n", render("%p.bar.foo{:class => nil} nil")) - assert_equal("

    nil

    \n", render("%p.foo{{:class => 'bar'}, :class => nil} nil")) - assert_equal("

    nil

    \n", render("%p.foo{{:class => nil}, :class => 'bar'} nil")) - end - - def test_locals - assert_equal("

    Paragraph!

    \n", render("%p= text", :locals => { :text => "Paragraph!" })) - end - - def test_dynamic_attrs_shouldnt_register_as_literal_values - assert_equal("

    \n", render('%p{:a => "b#{1 + 1}c"}')) - assert_equal("

    \n", render("%p{:a => 'b' + (1 + 1).to_s + 'c'}")) - end - - def test_dynamic_attrs_with_self_closed_tag - assert_equal("\nc\n", render("%a{'b' => 1 + 1}/\n= 'c'\n")) - end - - EXCEPTION_MAP.each do |key, value| - define_method("test_exception (#{key.inspect})") do - begin - render(key, :filename => __FILE__) - rescue Exception => err - value = [value] unless value.is_a?(Array) - expected_message, line_no = value - line_no ||= key.split("\n").length - - if expected_message == :compile - if Haml::Util.ruby1_8? - assert_match(/^compile error\n/, err.message, "Line: #{key}") - else - assert_match(/^#{Regexp.quote __FILE__}:#{line_no}: syntax error,/, err.message, "Line: #{key}") - end - else - assert_equal(expected_message, err.message, "Line: #{key}") - end - - if Haml::Util.ruby1_8? - # Sometimes, the first backtrace entry is *only* in the message. - # No idea why. - bt = - if expected_message == :compile && err.message.include?("\n") - err.message.split("\n", 2)[1] - else - err.backtrace[0] - end - assert_match(/^#{Regexp.escape(__FILE__)}:#{line_no}/, bt, "Line: #{key}") - end - else - assert(false, "Exception not raised for\n#{key}") - end - end - end - - def test_exception_line - render("a\nb\n!!!\n c\nd") - rescue Haml::SyntaxError => e - assert_equal("(test_exception_line):4", e.backtrace[0]) - else - assert(false, '"a\nb\n!!!\n c\nd" doesn\'t produce an exception') - end - - def test_exception - render("%p\n hi\n %a= undefined\n= 12") - rescue Exception => e - assert_match("(test_exception):3", e.backtrace[0]) - else - # Test failed... should have raised an exception - assert(false) - end - - def test_compile_error - render("a\nb\n- fee)\nc") - rescue Exception => e - assert_match(/\(test_compile_error\):3: syntax error/i, e.message) - else - assert(false, - '"a\nb\n- fee)\nc" doesn\'t produce an exception!') - end - - def test_unbalanced_brackets - render('foo #{1 + 5} foo #{6 + 7 bar #{8 + 9}') - rescue Haml::SyntaxError => e - assert_equal("Unbalanced brackets.", e.message) - end - - def test_balanced_conditional_comments - assert_equal("\n", - render("/[if !(IE 6)|(IE 7)] Bracket: ]")) - end - - def test_empty_filter - assert_equal(< - // - -END - end - - def test_ugly_filter - assert_equal(< true)) -#foo { - bar: baz; } -END - end - - def test_css_filter - assert_equal(< - /**/ - -HTML -:css - #foo { - bar: baz; } -HAML - end - - def test_local_assigns_dont_modify_class - assert_equal("bar\n", render("= foo", :locals => {:foo => 'bar'})) - assert_equal(nil, defined?(foo)) - end - - def test_object_ref_with_nil_id - user = User.new - assert_equal("

    New User

    \n", - render("%p[user] New User", :locals => {:user => user})) - end - - def test_object_ref_before_attrs - user = User.new 42 - assert_equal("

    New User

    \n", - render("%p[user]{:style => 'width: 100px;'} New User", :locals => {:user => user})) - end - - def test_object_ref_with_custom_haml_class - custom = CustomHamlClass.new 42 - assert_equal("

    My Thing

    \n", - render("%p[custom]{:style => 'width: 100px;'} My Thing", :locals => {:custom => custom})) - end - - def test_non_literal_attributes - assert_equal("

    \n", - render("%p{a2, a1, :a3 => 'baz'}/", - :locals => {:a1 => {:a1 => 'foo'}, :a2 => {:a2 => 'bar'}})) - end - - def test_render_should_accept_a_binding_as_scope - string = "This is a string!" - string.instance_variable_set("@var", "Instance variable") - b = string.instance_eval do - var = "Local variable" - binding - end - - assert_equal("

    THIS IS A STRING!

    \n

    Instance variable

    \n

    Local variable

    \n", - render("%p= upcase\n%p= @var\n%p= var", :scope => b)) - end - - def test_yield_should_work_with_binding - assert_equal("12\nFOO\n", render("= yield\n= upcase", :scope => "foo".instance_eval{binding}) { 12 }) - end - - def test_yield_should_work_with_def_method - s = "foo" - engine("= yield\n= upcase").def_method(s, :render) - assert_equal("12\nFOO\n", s.render { 12 }) - end - - def test_def_method_with_module - engine("= yield\n= upcase").def_method(String, :render_haml) - assert_equal("12\nFOO\n", "foo".render_haml { 12 }) - end - - def test_def_method_locals - obj = Object.new - engine("%p= foo\n.bar{:baz => baz}= boom").def_method(obj, :render, :foo, :baz, :boom) - assert_equal("

    1

    \n
    3
    \n", obj.render(:foo => 1, :baz => 2, :boom => 3)) - end - - def test_render_proc_locals - proc = engine("%p= foo\n.bar{:baz => baz}= boom").render_proc(Object.new, :foo, :baz, :boom) - assert_equal("

    1

    \n
    3
    \n", proc[:foo => 1, :baz => 2, :boom => 3]) - end - - def test_render_proc_with_binding - assert_equal("FOO\n", engine("= upcase").render_proc("foo".instance_eval{binding}).call) - end - - def test_haml_buffer_gets_reset_even_with_exception - scope = Object.new - render("- raise Haml::Error", :scope => scope) - assert(false, "Expected exception") - rescue Exception - assert_nil(scope.send(:haml_buffer)) - end - - def test_def_method_haml_buffer_gets_reset_even_with_exception - scope = Object.new - engine("- raise Haml::Error").def_method(scope, :render) - scope.render - assert(false, "Expected exception") - rescue Exception - assert_nil(scope.send(:haml_buffer)) - end - - def test_render_proc_haml_buffer_gets_reset_even_with_exception - scope = Object.new - proc = engine("- raise Haml::Error").render_proc(scope) - proc.call - assert(false, "Expected exception") - rescue Exception - assert_nil(scope.send(:haml_buffer)) - end - - def test_ugly_true - assert_equal("
    \n
    \n

    hello world

    \n
    \n
    \n", - render("#outer\n #inner\n %p hello world", :ugly => true)) - - assert_equal("

    #{'s' * 75}

    \n", - render("%p #{'s' * 75}", :ugly => true)) - - assert_equal("

    #{'s' * 75}

    \n", - render("%p= 's' * 75", :ugly => true)) - end - - def test_auto_preserve_unless_ugly - assert_equal("
    foo
    bar
    \n", render('%pre="foo\nbar"')) - assert_equal("
    foo\nbar
    \n", render("%pre\n foo\n bar")) - assert_equal("
    foo\nbar
    \n", render('%pre="foo\nbar"', :ugly => true)) - assert_equal("
    foo\nbar
    \n", render("%pre\n foo\n bar", :ugly => true)) - end - - def test_xhtml_output_option - assert_equal "

    \n
    \n

    \n", render("%p\n %br", :format => :xhtml) - assert_equal "
    \n", render("%a/", :format => :xhtml) - end - - def test_arbitrary_output_option - assert_raise_message(Haml::Error, "Invalid output format :html1") do - engine("%br", :format => :html1) - end - end - - def test_static_hashes - assert_equal("\n", render("%a{:b => 'a => b'}", :suppress_eval => true)) - assert_equal("\n", render("%a{:b => 'a, b'}", :suppress_eval => true)) - assert_equal("\n", render('%a{:b => "a\tb"}', :suppress_eval => true)) - assert_equal("\n", render('%a{:b => "a\\#{foo}b"}', :suppress_eval => true)) - end - - def test_dynamic_hashes_with_suppress_eval - assert_equal("\n", render('%a{:b => "a #{1 + 1} b", :c => "d"}', :suppress_eval => true)) - end - - def test_utf8_attrs - assert_equal("\n", render("%a{:href => 'héllo'}")) - assert_equal("\n", render("%a(href='héllo')")) - end - - # HTML 4.0 - - def test_html_has_no_self_closing_tags - assert_equal "

    \n
    \n

    \n", render("%p\n %br", :format => :html4) - assert_equal "
    \n", render("%br/", :format => :html4) - end - - def test_html_renders_empty_node_with_closing_tag - assert_equal "
    \n", render(".foo", :format => :html4) - end - - def test_html_doesnt_add_slash_to_self_closing_tags - assert_equal "\n", render("%a/", :format => :html4) - assert_equal "\n", render("%a{:foo => 1 + 1}/", :format => :html4) - assert_equal "\n", render("%meta", :format => :html4) - assert_equal "\n", render("%meta{:foo => 1 + 1}", :format => :html4) - end - - def test_html_ignores_xml_prolog_declaration - assert_equal "", render('!!! XML', :format => :html4) - end - - def test_html_has_different_doctype - assert_equal %{\n}, - render('!!!', :format => :html4) - end - - # because anything before the doctype triggers quirks mode in IE - def test_xml_prolog_and_doctype_dont_result_in_a_leading_whitespace_in_html - assert_no_match(/^\s+/, render("!!! xml\n!!!", :format => :html4)) - end - - # HTML5 - def test_html5_doctype - assert_equal %{\n}, render('!!!', :format => :html5) - end - - # HTML5 custom data attributes - def test_html5_data_attributes - assert_equal("
    \n", - render("%div{:data => {:author_id => 123, :foo => 'bar', :biz => 'baz'}}")) - - assert_equal("
    \n", - render("%div{:data => {:one_plus_one => 1+1}}")) - - assert_equal("
    \n", - render(%{%div{:data => {:foo => %{Here's a "quoteful" string.}}}})) #' - end - - def test_html5_data_attributes_with_multiple_defs - # Should always use the more-explicit attribute - assert_equal("
    \n", - render("%div{:data => {:foo => 'first'}, 'data-foo' => 'second'}")) - assert_equal("
    \n", - render("%div{'data-foo' => 'first', :data => {:foo => 'second'}}")) - end - - def test_html5_data_attributes_with_attr_method - Haml::Helpers.module_eval do - def data_hash - {:data => {:foo => "bar", :baz => "bang"}} - end - - def data_val - {:data => "dat"} - end - end - - assert_equal("
    \n", - render("%div{data_hash, :data => {:foo => 'blip', :brat => 'wurst'}}")) - assert_equal("
    \n", - render("%div{data_hash, 'data-foo' => 'blip'}")) - assert_equal("
    \n", - render("%div{data_hash, :data => 'dat'}")) - assert_equal("
    \n", - render("%div{data_val, :data => {:foo => 'blip', :brat => 'wurst'}}")) - end - - # New attributes - - def test_basic_new_attributes - assert_equal("
    bar\n", render("%a() bar")) - assert_equal("bar\n", render("%a(href='foo') bar")) - assert_equal("baz\n", render(%q{%a(b="c" c='d' d="e") baz})) - end - - def test_new_attribute_ids - assert_equal("
    \n", render("#foo(id='bar')")) - assert_equal("
    \n", render("#foo{:id => 'bar'}(id='baz')")) - assert_equal("
    \n", render("#foo(id='baz'){:id => 'bar'}")) - foo = User.new(42) - assert_equal("
    \n", - render("#foo(id='baz'){:id => 'bar'}[foo]", :locals => {:foo => foo})) - assert_equal("
    \n", - render("#foo(id='baz')[foo]{:id => 'bar'}", :locals => {:foo => foo})) - assert_equal("
    \n", - render("#foo[foo](id='baz'){:id => 'bar'}", :locals => {:foo => foo})) - assert_equal("
    \n", - render("#foo[foo]{:id => 'bar'}(id='baz')", :locals => {:foo => foo})) - end - - def test_new_attribute_classes - assert_equal("
    \n", render(".foo(class='bar')")) - assert_equal("
    \n", render(".foo{:class => 'bar'}(class='baz')")) - assert_equal("
    \n", render(".foo(class='baz'){:class => 'bar'}")) - foo = User.new(42) - assert_equal("
    \n", - render(".foo(class='baz'){:class => 'bar'}[foo]", :locals => {:foo => foo})) - assert_equal("
    \n", - render(".foo[foo](class='baz'){:class => 'bar'}", :locals => {:foo => foo})) - assert_equal("
    \n", - render(".foo[foo]{:class => 'bar'}(class='baz')", :locals => {:foo => foo})) - end - - def test_dynamic_new_attributes - assert_equal("bar\n", render("%a(href=foo) bar", :locals => {:foo => 12})) - assert_equal("bar\n", render("%a(b=b c='13' d=d) bar", :locals => {:b => 12, :d => 14})) - end - - def test_new_attribute_interpolation - assert_equal("bar\n", render('%a(href="1#{1 + 1}") bar')) - assert_equal("bar\n", render(%q{%a(href='2: #{1 + 1}, 3: #{foo}') bar}, :locals => {:foo => 3})) - assert_equal(%Q{bar\n}, render('%a(href="1\#{1 + 1}") bar')) - end - - def test_truthy_new_attributes - assert_equal("bar\n", render("%a(href) bar")) - assert_equal("bar\n", render("%a(href bar='baz') bar", :format => :html5)) - assert_equal("bar\n", render("%a(href=true) bar")) - assert_equal("bar\n", render("%a(href=false) bar")) - end - - def test_new_attribute_parsing - assert_equal("bar\n", render("%a(a2=b2) bar", :locals => {:b2 => 'b2'})) - assert_equal(%Q{bar\n}, render(%q{%a(a="#{'foo"bar'}") bar})) #' - assert_equal(%Q{bar\n}, render(%q{%a(a="#{"foo'bar"}") bar})) #' - assert_equal(%Q{bar\n}, render(%q{%a(a='foo"bar') bar})) - assert_equal(%Q{bar\n}, render(%q{%a(a="foo'bar") bar})) - assert_equal("bar\n", render("%a(a:b='foo') bar")) - assert_equal("bar\n", render("%a(a = 'foo' b = 'bar') bar")) - assert_equal("bar\n", render("%a(a = foo b = bar) bar", :locals => {:foo => 'foo', :bar => 'bar'})) - assert_equal("(b='bar')\n", render("%a(a='foo')(b='bar')")) - assert_equal("baz\n", render("%a(a='foo)bar') baz")) - assert_equal("baz\n", render("%a( a = 'foo' ) baz")) - end - - def test_new_attribute_escaping - assert_equal(%Q{bar\n}, render(%q{%a(a="foo \" bar") bar})) - assert_equal(%Q{bar\n}, render(%q{%a(a="foo \\\\\" bar") bar})) - - assert_equal(%Q{bar\n}, render(%q{%a(a='foo \' bar') bar})) - assert_equal(%Q{bar\n}, render(%q{%a(a='foo \\\\\' bar') bar})) - - assert_equal(%Q{bar\n}, render(%q{%a(a="foo \\\\ bar") bar})) - assert_equal(%Q{bar\n}, render(%q{%a(a="foo \#{1 + 1} bar") bar})) - end - - def test_multiline_new_attribute - assert_equal("bar\n", render("%a(a='b'\n c='d') bar")) - assert_equal("bar\n", - render("%a(a='b' b='c'\n c='d' d=e\n e='f' f='j') bar", :locals => {:e => 'e'})) - end - - def test_new_and_old_attributes - assert_equal("bar\n", render("%a(a='b'){:c => 'd'} bar")) - assert_equal("bar\n", render("%a{:c => 'd'}(a='b') bar")) - assert_equal("bar\n", render("%a(c='d'){:a => 'b'} bar")) - assert_equal("bar\n", render("%a{:a => 'b'}(c='d') bar")) - - # Old-style always takes precedence over new-style, - # because theoretically old-style could have arbitrary end-of-method-call syntax. - assert_equal("bar\n", render("%a{:a => 'b'}(a='d') bar")) - assert_equal("bar\n", render("%a(a='d'){:a => 'b'} bar")) - - assert_equal("bar\n", - render("%a{:a => 'b',\n:b => 'c'}(c='d'\nd='e') bar")) - - locals = {:b => 'b', :d => 'd'} - assert_equal("

    \n", render("%p{:a => b}(c=d)", :locals => locals)) - assert_equal("

    \n", render("%p(a=b){:c => d}", :locals => locals)) - end - - # Ruby Multiline - - def test_silent_ruby_multiline - assert_equal(<foo

    -HTML -- foo = ["bar", - "baz", - "bang"] -= foo.join(", ") -%p foo -HAML - end - - def test_loud_ruby_multiline - assert_equal(<foo

    -

    bar

    -HTML -= ["bar", - "baz", - "bang"].join(", ") -%p foo -%p bar -HAML - end - - def test_escaped_loud_ruby_multiline - assert_equal(<foo

    -

    bar

    -HTML -&= ["bar<", - "baz", - "bang"].join(", ") -%p foo -%p bar -HAML - end - - def test_unescaped_loud_ruby_multiline - assert_equal(< true)) -bar<, baz, bang -

    foo

    -

    bar

    -HTML -!= ["bar<", - "baz", - "bang"].join(", ") -%p foo -%p bar -HAML - end - - def test_flattened_loud_ruby_multiline - assert_equal(<bar baz bang -

    foo

    -

    bar

    -HTML -~ "
    " + ["bar",
    -             "baz",
    -             "bang"].join("\\n") + "
    " -%p foo -%p bar -HAML - end - - def test_loud_ruby_multiline_with_block - assert_equal(<foo

    -

    bar

    -HTML -= ["bar", - "baz", - "bang"].map do |str| - - str.gsub("ba", - "fa") -%p foo -%p bar -HAML - end - - def test_silent_ruby_multiline_with_block - assert_equal(<foo

    -

    bar

    -HTML -- ["bar", - "baz", - "bang"].map do |str| - = str.gsub("ba", - "fa") -%p foo -%p bar -HAML - end - - def test_ruby_multiline_in_tag - assert_equal(<foo, bar, baz

    -

    foo

    -

    bar

    -HTML -%p= ["foo", - "bar", - "baz"].join(", ") -%p foo -%p bar -HAML - end - - def test_escaped_ruby_multiline_in_tag - assert_equal(<foo<, bar, baz

    -

    foo

    -

    bar

    -HTML -%p&= ["foo<", - "bar", - "baz"].join(", ") -%p foo -%p bar -HAML - end - - def test_unescaped_ruby_multiline_in_tag - assert_equal(< true)) -

    foo<, bar, baz

    -

    foo

    -

    bar

    -HTML -%p!= ["foo<", - "bar", - "baz"].join(", ") -%p foo -%p bar -HAML - end - - def test_ruby_multiline_with_normal_multiline - assert_equal(<foo

    -

    bar

    -HTML -= "foo" + | - "bar" + | - ["bar", | - "baz", - "bang"].join(", ") -%p foo -%p bar -HAML - end - - def test_ruby_multiline_after_filter - assert_equal(<foo

    -

    bar

    -HTML -:plain - foo - bar -= ["bar", - "baz", - "bang"].join(", ") -%p foo -%p bar -HAML - end - - # Encodings - - def test_utf_8_bom - assert_equal < -

    baz

    -
    -HTML -\xEF\xBB\xBF.foo - %p baz -HAML - end - - unless Haml::Util.ruby1_8? - def test_default_encoding - assert_equal(Encoding.find("utf-8"), render(< "ascii-8bit")) -

    bâr

    -

    föö

    -HTML -%p bâr -%p föö -HAML - end - - def test_convert_template_render_proc - assert_converts_template_properly {|e| e.render_proc.call} - end - - def test_convert_template_render - assert_converts_template_properly {|e| e.render} - end - - def test_convert_template_def_method - assert_converts_template_properly do |e| - o = Object.new - e.def_method(o, :render) - o.render - end - end - - def test_encoding_error - render("foo\nbar\nb\xFEaz".force_encoding("utf-8")) - assert(false, "Expected exception") - rescue Haml::Error => e - assert_equal(3, e.line) - assert_equal('Invalid UTF-8 character "\xFE"', e.message) - end - - def test_ascii_incompatible_encoding_error - template = "foo\nbar\nb_z".encode("utf-16le") - template[9] = "\xFE".force_encoding("utf-16le") - render(template) - assert(false, "Expected exception") - rescue Haml::Error => e - assert_equal(3, e.line) - assert_equal('Invalid UTF-16LE character "\xFE"', e.message) - end - - def test_same_coding_comment_as_encoding - assert_renders_encoded(<bâr

    -

    föö

    -HTML --# coding: utf-8 -%p bâr -%p föö -HAML - end - - def test_coding_comments - assert_valid_encoding_comment("-# coding: ibm866") - assert_valid_encoding_comment("-# CodINg: IbM866") - assert_valid_encoding_comment("-#coding:ibm866") - assert_valid_encoding_comment("-# CodINg= ibm866") - assert_valid_encoding_comment("-# foo BAR FAOJcoding: ibm866") - assert_valid_encoding_comment("-# coding: ibm866 ASFJ (&(&#!$") - assert_valid_encoding_comment("-# -*- coding: ibm866") - assert_valid_encoding_comment("-# coding: ibm866 -*- coding: blah") - assert_valid_encoding_comment("-# -*- coding: ibm866 -*-") - assert_valid_encoding_comment("-# -*- encoding: ibm866 -*-") - assert_valid_encoding_comment('-# -*- coding: "ibm866" -*-') - assert_valid_encoding_comment("-#-*-coding:ibm866-*-") - assert_valid_encoding_comment("-#-*-coding:ibm866-*-") - assert_valid_encoding_comment("-# -*- foo: bar; coding: ibm866; baz: bang -*-") - assert_valid_encoding_comment("-# foo bar coding: baz -*- coding: ibm866 -*-") - assert_valid_encoding_comment("-# -*- coding: ibm866 -*- foo bar coding: baz") - end - - def test_different_coding_than_system - assert_renders_encoded(<Ñ‚ÐЬ

    -HTML -%p Ñ‚ÐЬ -HAML - end - end - - private - - def assert_valid_encoding_comment(comment) - assert_renders_encoded(<ЖЛЫ

    -

    Ñ‚ÐЬ

    -HTML -#{comment} -%p ЖЛЫ -%p Ñ‚ÐЬ -HAML - end - - def assert_converts_template_properly - engine = Haml::Engine.new(< "macRoman") -%p bâr -%p föö -HAML - assert_encoded_equal(<bâr

    -

    föö

    -HTML - end - - def assert_renders_encoded(html, haml) - result = render(haml) - assert_encoded_equal html, result - end - - def assert_encoded_equal(expected, actual) - assert_equal expected.encoding, actual.encoding - assert_equal expected, actual - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/_av_partial_1.erb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/_av_partial_1.erb deleted file mode 100644 index 6cf41eb59c..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/_av_partial_1.erb +++ /dev/null @@ -1,12 +0,0 @@ -

    This is a pretty complicated partial

    -
    -

    It has several nested partials,

    -
      - <% 5.times do %> -
    • - Partial: - <% @nesting = 5 %> - <%= render :partial => 'haml/erb/av_partial_2' %> - <% end %> -
    -
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/_av_partial_2.erb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/_av_partial_2.erb deleted file mode 100644 index 017d9068a6..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/_av_partial_2.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% @nesting -= 1 %> -
    -

    This is a crazy deep-nested partial.

    -

    Nesting level <%= @nesting %>

    - <% if @nesting > 0 %> - <%= render :partial => 'haml/erb/av_partial_2' %> - <% end %> -
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/action_view.erb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/action_view.erb deleted file mode 100644 index c81586f36f..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/action_view.erb +++ /dev/null @@ -1,62 +0,0 @@ - - - - Hampton Catlin Is Totally Awesome - - - -

    - This is very much like the standard template, - except that it has some ActionView-specific stuff. - It's only used for benchmarking. -

    -
    - <%= render :partial => 'haml/erb/av_partial_1' %> -
    - -
    - Yes, ladies and gentileman. He is just that egotistical. - Fantastic! This should be multi-line output - The question is if this would translate! Ahah! - <%= 1 + 9 + 8 + 2 %> - <%# numbers should work and this should be ignored %> -
    - <% 120.times do |number| -%> - <%= number %> - <% end -%> -
    <%= " Quotes should be loved! Just like people!" %>
    - Wow. -

    - <%= "Holy cow " + - "multiline " + - "tags! " + - "A pipe (|) even!" %> - <%= [1, 2, 3].collect { |n| "PipesIgnored|" } %> - <%= [1, 2, 3].collect { |n| - n.to_s - }.join("|") %> -

    -
    - <% foo = String.new - foo << "this" - foo << " shouldn't" - foo << " evaluate" %> - <%= foo + "but now it should!" %> - <%# Woah crap a comment! %> -
    -
      - <% ('a'..'f').each do |a|%> -
    • <%= a %> - <% end %> -
      <%= @should_eval = "with this text" %>
      - <%= [ 104, 101, 108, 108, 111 ].map do |byte| - byte.chr - end %> - - - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/standard.erb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/standard.erb deleted file mode 100644 index 0cc8ea7757..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/erb/standard.erb +++ /dev/null @@ -1,55 +0,0 @@ - - - - Hampton Catlin Is Totally Awesome - - - - -
      - Yes, ladies and gentileman. He is just that egotistical. - Fantastic! This should be multi-line output - The question is if this would translate! Ahah! - <%= 1 + 9 + 8 + 2 %> - <%# numbers should work and this should be ignored %> -
      - <% 120.times do |number| -%> - <%= number %> - <% end -%> -
      <%= " Quotes should be loved! Just like people!" %>
      - Wow. -

      - <%= "Holy cow " + - "multiline " + - "tags! " + - "A pipe (|) even!" %> - <%= [1, 2, 3].collect { |n| "PipesIgnored|" }.join %> - <%= [1, 2, 3].collect { |n| - n.to_s - }.join("|") %> -

      - <% bar = 17 %> -
      - <% foo = String.new - foo << "this" - foo << " shouldn't" - foo << " evaluate" %> - <%= foo + "but now it should!" %> - <%# Woah crap a comment! %> -
      -
        - <% ('a'..'f').each do |a|%> -
      • <%= a %>
      • - <% end %> -
        <%= @should_eval = "with this text" %>
        - <%= "foo".each_line do |line| - nil - end %> - - - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/helper_test.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/helper_test.rb deleted file mode 100755 index 3aaa60e5c5..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/helper_test.rb +++ /dev/null @@ -1,450 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../test_helper' - -class ActionView::Base - def nested_tag - content_tag(:span) {content_tag(:div) {"something"}} - end - - def wacky_form - form_tag("/foo") {"bar"} - end -end - -module Haml::Helpers - def something_that_uses_haml_concat - haml_concat('foo').to_s - end -end - -class HelperTest < Test::Unit::TestCase - Post = Struct.new('Post', :body, :error_field, :errors) - class PostErrors - def on(name) - return unless name == 'error_field' - ["Really bad error"] - end - alias_method :full_messages, :on - - def [](name) - on(name) || [] - end - end - - def setup - @base = ActionView::Base.new - @base.controller = ActionController::Base.new - - if defined?(ActionController::Response) - # This is needed for >=3.0.0 - @base.controller.response = ActionController::Response.new - end - - @base.instance_variable_set('@post', Post.new("Foo bar\nbaz", nil, PostErrors.new)) - end - - def render(text, options = {}) - if options == :action_view - @base.render :inline => text, :type => :haml - else - scope = options.delete :scope_object - Haml::Engine.new(text, options).to_html(scope ? scope : Object.new) - end - end - - def test_flatten - assert_equal("FooBar", Haml::Helpers.flatten("FooBar")) - - assert_equal("FooBar", Haml::Helpers.flatten("Foo\rBar")) - - assert_equal("Foo Bar", Haml::Helpers.flatten("Foo\nBar")) - - assert_equal("Hello World! YOU ARE FLAT? OMGZ!", - Haml::Helpers.flatten("Hello\nWorld!\nYOU ARE \rFLAT?\n\rOMGZ!")) - end - - def test_list_of_should_render_correctly - assert_equal("
      • 1
      • \n
      • 2
      • \n", render("= list_of([1, 2]) do |i|\n = i")) - assert_equal("
      • [1]
      • \n", render("= list_of([[1]]) do |i|\n = i.inspect")) - assert_equal("
      • \n

        Fee

        \n

        A word!

        \n
      • \n
      • \n

        Fi

        \n

        A word!

        \n
      • \n
      • \n

        Fo

        \n

        A word!

        \n
      • \n
      • \n

        Fum

        \n

        A word!

        \n
      • \n", - render("= list_of(['Fee', 'Fi', 'Fo', 'Fum']) do |title|\n %h1= title\n %p A word!")) - end - - def test_buffer_access - assert(render("= buffer") =~ /#/) - assert_equal(render("= (buffer == _hamlout)"), "true\n") - end - - def test_tabs - assert_equal("foo\n bar\nbaz\n", render("foo\n- tab_up\nbar\n- tab_down\nbaz")) - assert_equal("

        tabbed

        \n", render("- buffer.tabulation=5\n%p tabbed")) - end - - def test_with_tabs - assert_equal(< "<%= flatten('Foo\\nBar') %>") - rescue NoMethodError, Haml::Util.av_template_class(:Error) - proper_behavior = true - end - assert(proper_behavior) - - begin - ActionView::Base.new.render(:inline => "<%= concat('foo') %>") - rescue ArgumentError, NameError - proper_behavior = true - end - assert(proper_behavior) - end - - def test_action_view_included - assert(Haml::Helpers.action_view?) - end - - def test_form_tag - # This is usually provided by ActionController::Base. - def @base.protect_against_forgery?; false; end - assert_equal(<#{rails_form_opener} -

        bar

        - baz - -HTML -#{rails_block_helper_char} form_tag 'foo' do - %p bar - %strong baz -HAML - end - - def test_text_area - assert_equal(%(\n), - render('= text_area_tag "body", "Foo\nBar\n Baz\n Boom"', :action_view)) - - assert_equal(%(\n), - render('= text_area :post, :body', :action_view)) - - assert_equal(%(
        Foo bar
           baz
        \n), - render('= content_tag "pre", "Foo bar\n baz"', :action_view)) - end - - def test_capture_haml - assert_equal(<13

        \\n" -HTML -- (foo = capture_haml(13) do |a| - %p= a -- end; nil) -= foo.dump -HAML - end - - def test_content_tag_block - assert_equal(<

        bar

        -bar -
    -HTML -#{rails_block_helper_char} content_tag :div do - %p bar - %strong bar -HAML - end - - def test_content_tag_error_wrapping - def @base.protect_against_forgery?; false; end - error_class = Haml::Util.ap_geq_3? ? "field_with_errors" : "fieldWithErrors" - assert_equal(<#{rails_form_opener} -
    - -HTML -#{rails_block_helper_char} form_for #{form_for_calling_convention('post')}, :url => '' do |f| - = f.label 'error_field' -HAML - end - - def test_form_tag_in_helper_with_string_block - def @base.protect_against_forgery?; false; end - assert_equal(<#{rails_form_opener}bar -HTML -#{rails_block_helper_char} wacky_form -HAML - end - - def test_haml_tag_name_attribute_with_id - assert_equal("

    \n", render("- haml_tag 'p#some_id'")) - end - - def test_haml_tag_name_attribute_with_colon_id - assert_equal("

    \n", render("- haml_tag 'p#some:id'")) - end - - def test_haml_tag_without_name_but_with_id - assert_equal("
    \n", render("- haml_tag '#some_id'")) - end - - def test_haml_tag_without_name_but_with_class - assert_equal("
    \n", render("- haml_tag '.foo'")) - end - - def test_haml_tag_without_name_but_with_colon_class - assert_equal("
    \n", render("- haml_tag '.foo:bar'")) - end - - def test_haml_tag_name_with_id_and_class - assert_equal("

    \n", render("- haml_tag 'p#some_id.foo'")) - end - - def test_haml_tag_name_with_class - assert_equal("

    \n", render("- haml_tag 'p.foo'")) - end - - def test_haml_tag_name_with_class_and_id - assert_equal("

    \n", render("- haml_tag 'p.foo#some_id'")) - end - - def test_haml_tag_name_with_id_and_multiple_classes - assert_equal("

    \n", render("- haml_tag 'p#some_id.foo.bar'")) - end - - def test_haml_tag_name_with_multiple_classes_and_id - assert_equal("

    \n", render("- haml_tag 'p.foo.bar#some_id'")) - end - - def test_haml_tag_name_and_attribute_classes_merging - assert_equal("

    \n", render("- haml_tag 'p#some_id.foo', :class => 'bar'")) - end - - def test_haml_tag_name_and_attribute_classes_merging - assert_equal("

    \n", render("- haml_tag 'p.foo', :class => 'bar'")) - end - - def test_haml_tag_name_merges_id_and_attribute_id - assert_equal("

    \n", render("- haml_tag 'p#foo', :id => 'bar'")) - end - - def test_haml_tag_attribute_html_escaping - assert_equal("

    baz

    \n", render("%p{:id => 'foo&bar'} baz", :escape_html => true)) - end - - def test_haml_tag_autoclosed_tags_are_closed - assert_equal("
    \n", render("- haml_tag :br, :class => 'foo'")) - end - - def test_haml_tag_with_class_array - assert_equal("

    foo

    \n", render("- haml_tag :p, 'foo', :class => %w[a b]")) - assert_equal("

    foo

    \n", render("- haml_tag 'p.c.d', 'foo', :class => %w[a b]")) - end - - def test_haml_tag_with_id_array - assert_equal("

    foo

    \n", render("- haml_tag :p, 'foo', :id => %w[a b]")) - assert_equal("

    foo

    \n", render("- haml_tag 'p#c', 'foo', :id => %w[a b]")) - end - - def test_haml_tag_with_data_hash - assert_equal("

    foo

    \n", - render("- haml_tag :p, 'foo', :data => {:foo => 'bar', :baz => true}")) - end - - def test_haml_tag_non_autoclosed_tags_arent_closed - assert_equal("

    \n", render("- haml_tag :p")) - end - - def test_haml_tag_renders_text_on_a_single_line - assert_equal("

    #{'a' * 100}

    \n", render("- haml_tag :p, 'a' * 100")) - end - - def test_haml_tag_raises_error_for_multiple_content - assert_raise(Haml::Error) { render("- haml_tag :p, 'foo' do\n bar") } - end - - def test_haml_tag_flags - assert_equal("

    \n", render("- haml_tag :p, :/")) - assert_equal("

    kumquat

    \n", render("- haml_tag :p, :< do\n kumquat")) - - assert_raise(Haml::Error) { render("- haml_tag :p, 'foo', :/") } - assert_raise(Haml::Error) { render("- haml_tag :p, :/ do\n foo") } - end - - def test_haml_tag_error_return - assert_raise(Haml::Error) { render("= haml_tag :p") } - end - - def test_haml_tag_with_multiline_string - assert_equal(< - foo - bar - baz -

    -HTML -- haml_tag :p, "foo\\nbar\\nbaz" -HAML - end - - def test_haml_concat_with_multiline_string - assert_equal(< - foo - bar - baz -

    -HTML -%p - - haml_concat "foo\\nbar\\nbaz" -HAML - end - - def test_haml_tag_with_ugly - assert_equal(< true)) -

    -Hi! -

    -HTML -- haml_tag :p do - - haml_tag :strong, "Hi!" -HAML - end - - def test_is_haml - assert(!ActionView::Base.new.is_haml?) - assert_equal("true\n", render("= is_haml?")) - assert_equal("true\n", render("= is_haml?", :action_view)) - assert_equal("false", @base.render(:inline => '<%= is_haml? %>')) - assert_equal("false\n", render("= render :inline => '<%= is_haml? %>'", :action_view)) - end - - def test_page_class - controller = Struct.new(:controller_name, :action_name).new('troller', 'tion') - scope = Struct.new(:controller).new(controller) - result = render("%div{:class => page_class} MyDiv", :scope_object => scope) - expected = "
    MyDiv
    \n" - assert_equal expected, result - end - - def test_indented_capture - prior = Haml::Util.ap_geq_3? ? "" : " \n" - assert_equal("#{prior} Foo\n ", @base.render(:inline => " <% res = capture do %>\n Foo\n <% end %><%= res %>")) - end - - def test_capture_deals_properly_with_collections - Haml::Helpers.module_eval do - def trc(collection, &block) - collection.each do |record| - haml_concat capture_haml(record, &block) - end - end - end - - assert_equal("1\n\n2\n\n3\n\n", render("- trc([1, 2, 3]) do |i|\n = i.inspect")) - end - - def test_find_and_preserve_with_block - assert_equal("
    Foo
    Bar
    \nFoo\nBar\n", - render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar")) - end - - def test_find_and_preserve_with_block_and_tags - assert_equal("
    Foo\nBar
    \nFoo\nBar\n", - render("= find_and_preserve([]) do\n %pre\n Foo\n Bar\n Foo\n Bar")) - end - - def test_preserve_with_block - assert_equal("
    Foo
    Bar
    Foo Bar\n", - render("= preserve do\n %pre\n Foo\n Bar\n Foo\n Bar")) - end - - def test_init_haml_helpers - context = Object.new - class << context - include Haml::Helpers - end - context.init_haml_helpers - - result = context.capture_haml do - context.haml_tag :p, :attr => "val" do - context.haml_concat "Blah" - end - end - - assert_equal("

    \n Blah\n

    \n", result) - end - - def test_non_haml - assert_equal("false\n", render("= non_haml { is_haml? }")) - end - - def test_content_tag_nested - assert_equal "
    something
    ", render("= nested_tag", :action_view).strip - end - - def test_error_return - assert_raise(Haml::Error, < e - assert_equal 2, e.backtrace[1].scan(/:(\d+)/).first.first.to_i - end - - def test_error_return_line_in_helper - render("- something_that_uses_haml_concat") - assert false, "Expected Haml::Error" - rescue Haml::Error => e - assert_equal 16, e.backtrace[0].scan(/:(\d+)/).first.first.to_i - end - - class ActsLikeTag - # We want to be able to have people include monkeypatched ActionView helpers - # without redefining is_haml?. - # This is accomplished via Object#is_haml?, and this is a test for it. - include ActionView::Helpers::TagHelper - def to_s - content_tag :p, 'some tag content' - end - end - - def test_random_class_includes_tag_helper - assert_equal "

    some tag content

    ", ActsLikeTag.new.to_s - end - - def test_capture_with_nuke_outer - assert_equal "
    \n*
    hi there!
    \n", render(< hi there! -HAML - - assert_equal "
    \n*
    hi there!
    \n", render(< hi there! -HAML - end -end - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/html2haml/erb_tests.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/html2haml/erb_tests.rb deleted file mode 100644 index c3ac36f488..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/html2haml/erb_tests.rb +++ /dev/null @@ -1,440 +0,0 @@ -module ErbTests - def test_erb - assert_equal '- foo = bar', render_erb('<% foo = bar %>') - assert_equal '- foo = bar', render_erb('<% foo = bar -%>') - assert_equal '= h @item.title', render_erb('<%=h @item.title %>') - assert_equal '= h @item.title', render_erb('<%=h @item.title -%>') - end - - def test_inline_erb - assert_equal("%p= foo", render_erb("

    <%= foo %>

    ")) - end - - def test_non_inline_erb - assert_equal(< - <%= foo %> -

    -HTML - assert_equal(< - <%= foo %>

    -HTML - assert_equal(<<%= foo %> -

    -HTML - end - - def test_erb_in_cdata - assert_equal(< baz]]> -HTML - end - - def test_erb_in_script - assert_equal(< - function foo() { - return <%= foo.to_json %>; - } - -HTML - end - - def test_erb_in_style - assert_equal(< - foo { - bar: <%= "baz" %>; - } - -HTML - end - - def test_erb_in_line - assert_equal 'foo bar #{baz}', render_erb('foo bar <%= baz %>') - assert_equal 'foo bar #{baz}! Bang.', render_erb('foo bar <%= baz %>! Bang.') - end - - def test_erb_multi_in_line - assert_equal('foo bar #{baz}! Bang #{bop}.', - render_erb('foo bar <%= baz %>! Bang <%= bop %>.')) - assert_equal('foo bar #{baz}#{bop}!', - render_erb('foo bar <%= baz %><%= bop %>!')) - end - - def test_erb_with_html_special_chars - assert_equal '= 3 < 5 ? "OK" : "Your computer is b0rken"', - render_erb('<%= 3 < 5 ? "OK" : "Your computer is b0rken" %>') - end - - def test_erb_in_class_attribute - assert_equal "%div{:class => dyna_class} I have a dynamic attribute", - render_erb('
    I have a dynamic attribute
    ') - end - - def test_erb_in_id_attribute - assert_equal "%div{:id => dyna_id} I have a dynamic attribute", - render_erb('
    I have a dynamic attribute
    ') - end - - def test_erb_in_attribute_results_in_string_interpolation - assert_equal('%div{:id => "item_#{i}"} Ruby string interpolation FTW', - render_erb('
    Ruby string interpolation FTW
    ')) - end - - def test_erb_in_attribute_with_trailing_content - assert_equal('%div{:class => "#{12}!"} Bang!', - render_erb('
    Bang!
    ')) - end - - def test_erb_in_html_escaped_attribute - assert_equal '%div{:class => "foo"} Bang!', - render_erb('
    ">Bang!
    ') - end - - def test_erb_in_attribute_to_multiple_interpolations - assert_equal('%div{:class => "#{12} + #{13}"} Math is super', - render_erb('
    Math is super
    ')) - end - - def test_whitespace_eating_erb_tags - assert_equal '- form_for', render_erb('<%- form_for -%>') - end - - def test_interpolation_in_erb - assert_equal('= "Foo #{bar} baz"', render_erb('<%= "Foo #{bar} baz" %>')) - end - - def test_interpolation_in_erb_attrs - assert_equal('%p{:foo => "#{bar} baz"}', - render_erb('

    ">

    ')) - end - - def test_multiline_erb_silent_script - assert_equal(< - <% - foo - bar - baz - %> -

    foo

    -
    -ERB - end - - def test_multiline_erb_loud_script - assert_equal(< - <%= - foo + - bar.baz.bang + - baz - %> -

    foo

    -
    -ERB - end - - def test_weirdly_indented_multiline_erb_loud_script - assert_equal(< - <%= - foo + - bar.baz.bang + - baz - %> -

    foo

    -
    -ERB - end - - def test_two_multiline_erb_loud_scripts - assert_equal(< - <%= - foo + - bar.baz.bang + - baz - %> - <%= foo.bar do - bang - end %> -

    foo

    -
    -ERB - end - - def test_multiline_then_single_line_erb_loud_scripts - assert_equal(< - <%= - foo + - bar.baz.bang + - baz - %> - <%= foo.bar %> -

    foo

    -
    -ERB - end - - def test_multiline_erb_but_really_single_line - assert_equal(< - <%= - foo - %> -

    foo

    - -ERB - end - - ### Block Parsing - - def test_block_parsing - assert_equal(< -

    bar

    -<% end %> -ERB - end - - def test_block_parsing_with_args - assert_equal(< -

    bar

    -<% end %> -ERB - end - - def test_block_parsing_with_equals - assert_equal(< -

    bar

    -<% end %> -ERB - end - - def test_block_parsing_with_modified_end - assert_equal(< - blah -<% end.bip %> -ERB - end - - def test_block_parsing_with_modified_end_with_block - assert_equal(< - blah -<% end.bip do %> - brang -<% end %> -ERB - end - - def test_multiline_block_opener - assert_equal(< - foo -<% end %> -ERB - end - - def test_if_elsif_else_parsing - assert_equal(< -

    bar

    -<% elsif bar.foo("zip") %> -
    baz
    -<% else %> - bibble -<% end %> -ERB - end - - def test_case_when_parsing - assert_equal(< -<% when "bip" %> -

    bip

    -<% when "bop" %> -

    BOP

    -<% when bizzle.bang.boop.blip %> - BIZZLE BANG BOOP BLIP -<% end %> -ERB - - assert_equal(< -

    bip

    -<% when "bop" %> -

    BOP

    -<% when bizzle.bang.boop.blip %> - BIZZLE BANG BOOP BLIP -<% end %> -ERB - end - - def test_begin_rescue_ensure - assert_equal(< e - %p b -- ensure - %p c -HAML -<% begin %> -

    a

    -<% rescue FooException => e %> -

    b

    -<% ensure %> -

    c

    -<% end %> -ERB - end - - # Regression - - def test_tag_inside_block - assert_equal(< - <% foo.each do %> - - <% end %> - -ERB - end - - def test_silent_inside_block_inside_tag - assert_equal(< - <% foo.each do %> - <% haml_puts "foo" %> - <% end %> - -ERB - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/html2haml_test.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/html2haml_test.rb deleted file mode 100755 index 3ccf3af027..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/html2haml_test.rb +++ /dev/null @@ -1,336 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../test_helper' -require File.dirname(__FILE__) + '/html2haml/erb_tests' -require 'haml/html' - -class Html2HamlTest < Test::Unit::TestCase - def test_empty_render_should_remain_empty - assert_equal '', render('') - end - - def test_doctype - assert_equal '!!!', render("") - assert_equal '!!! 1.1', render('') - assert_equal '!!! Strict', render('') - assert_equal '!!! Frameset', render('') - assert_equal '!!! Mobile 1.2', render('') - assert_equal '!!! Basic 1.1', render('') - assert_equal '!!!', render('') - assert_equal '!!! Strict', render('') - assert_equal '!!! Frameset', render('') - assert_equal '!!!', render('') - end - - def test_id_and_class_should_be_removed_from_hash - assert_equal '%span#foo.bar', render(' ') - end - - def test_no_tag_name_for_div_if_class_or_id_is_present - assert_equal '#foo', render('
    ') - assert_equal '.foo', render('
    ') - end - - def test_multiple_class_names - assert_equal '.foo.bar.baz', render('
    ') - end - - def test_should_have_pretty_attributes - assert_equal('%input{:name => "login", :type => "text"}/', - render('')) - assert_equal('%meta{:content => "text/html", "http-equiv" => "Content-Type"}/', - render('')) - end - - def test_class_with_dot_and_hash - assert_equal('%div{:class => "foo.bar"}', render("
    ")) - assert_equal('%div{:class => "foo#bar"}', render("
    ")) - assert_equal('.foo.bar{:class => "foo#bar foo.bar"}', render("
    ")) - end - - def test_id_with_dot_and_hash - assert_equal('%div{:id => "foo.bar"}', render("
    ")) - assert_equal('%div{:id => "foo#bar"}', render("
    ")) - end - - def test_interpolation - assert_equal('Foo \#{bar} baz', render('Foo #{bar} baz')) - end - - def test_interpolation_in_attrs - assert_equal('%p{:foo => "\#{bar} baz"}', render('

    ')) - end - - def test_cdata - assert_equal(< -
    flop
    - -HAML -

    -

    flop
    - -]]>

    -HTML - end - - def test_self_closing_tag - assert_equal("%foo/", render("")) - end - - def test_inline_text - assert_equal("%p foo", render("

    foo

    ")) - end - - def test_inline_comment - assert_equal("/ foo", render("")) - assert_equal(< -

    bar

    -HTML - end - - def test_non_inline_comment - assert_equal(< -HTML - end - - def test_non_inline_text - assert_equal(< - foo -

    -HTML - assert_equal(< - foo

    -HTML - assert_equal(<foo -

    -HTML - end - - def test_script_tag - assert_equal(< - function foo() { - return "12" & "13"; - } - -HTML - end - - def test_script_tag_with_cdata - assert_equal(< - - -HTML - end - - def test_pre - assert_equal(<foo - bar -baz -HTML - end - - def test_pre_code - assert_equal(<foo - bar -baz -HTML - end - - def test_code_without_pre - assert_equal(<foo - bar -baz -HTML - end - - def test_conditional_comment - assert_equal(< - bar - baz - -HTML - end - - def test_style_to_css_filter - assert_equal(< - foo { - bar: baz; - } - -HTML - end - - def test_inline_conditional_comment - assert_equal(< bar baz -HTML - end - - def test_minus_in_tag - assert_equal("%p - foo bar -", render("

    - foo bar -

    ")) - end - - def test_equals_in_tag - assert_equal("%p = foo bar =", render("

    = foo bar =

    ")) - end - - def test_hash_in_tag - assert_equal("%p # foo bar #", render("

    # foo bar #

    ")) - end - - def test_comma_post_tag - assert_equal(< Foo - , - %span bar - Foo - %span> bar - , - %span baz -HAML -
    - Foo, bar - Foobar, baz -
    -HTML - end - - def test_comma_post_tag_with_text_before - assert_equal(< - Batch - Foo, Bar - -HTML - end - - begin - require 'haml/html/erb' - include ErbTests - rescue LoadError => e - puts "\n** Couldn't require #{e.message[/-- (.*)$/, 1]}, skipping some tests" - end - - # Encodings - - unless Haml::Util.ruby1_8? - def test_encoding_error - render("foo\nbar\nb\xFEaz".force_encoding("utf-8")) - assert(false, "Expected exception") - rescue Haml::Error => e - assert_equal(3, e.line) - assert_equal('Invalid UTF-8 character "\xFE"', e.message) - end - - def test_ascii_incompatible_encoding_error - template = "foo\nbar\nb_z".encode("utf-16le") - template[9] = "\xFE".force_encoding("utf-16le") - render(template) - assert(false, "Expected exception") - rescue Haml::Error => e - assert_equal(3, e.line) - assert_equal('Invalid UTF-16LE character "\xFE"', e.message) - end - end - - # Regression Tests - - def test_xhtml_strict_doctype - assert_equal('!!! Strict', render(< -HTML - end - - protected - - def render(text, options = {}) - Haml::HTML.new(text, options).render.rstrip - end - - def render_erb(text) - render(text, :erb => true) - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/markaby/standard.mab b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/markaby/standard.mab deleted file mode 100644 index aff8641624..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/markaby/standard.mab +++ /dev/null @@ -1,52 +0,0 @@ -self << '' -html(:xmlns=>'http://www.w3.org/1999/xhtml', 'xml:lang'=>'en-US') do - head do - title "Hampton Catlin Is Totally Awesome" - meta("http-equiv" => "Content-Type", :content => "text/html; charset=utf-8") - end - body do - # You're In my house now! - div :class => "header" do - self << %|Yes, ladies and gentileman. He is just that egotistical. - Fantastic! This should be multi-line output - The question is if this would translate! Ahah!| - self << 1 + 9 + 8 + 2 #numbers should work and this should be ignored - end - div(:id => "body") { self << "Quotes should be loved! Just like people!"} - 120.times do |number| - number - end - self << "Wow.|" - p do - self << "Holy cow " + - "multiline " + - "tags! " + - "A pipe (|) even!" - self << [1, 2, 3].collect { |n| "PipesIgnored|" } - self << [1, 2, 3].collect { |n| - n.to_s - }.join("|") - end - div(:class => "silent") do - foo = String.new - foo << "this" - foo << " shouldn't" - foo << " evaluate" - self << foo + " but now it should!" - # Woah crap a comment! - end - # That was a line that shouldn't close everything. - ul(:class => "really cool") do - ('a'..'f').each do |a| - li a - end - end - div((@should_eval = "with this text"), :id => "combo", :class => "of_divs_with_underscore") - [ 104, 101, 108, 108, 111 ].map do |byte| - byte.chr - end - div(:class => "footer") do - strong("This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works", :class => "shout") - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/mocks/article.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/mocks/article.rb deleted file mode 100644 index 805f8cad3d..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/mocks/article.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Article - attr_accessor :id, :title, :body - def initialize - @id, @title, @body = 1, 'Hello', 'World' - end -end \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/content_for_layout.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/content_for_layout.xhtml deleted file mode 100644 index 63bbd2297e..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/content_for_layout.xhtml +++ /dev/null @@ -1,12 +0,0 @@ - - - - -
    - Lorem ipsum dolor sit amet -
    -
    - Lorem ipsum dolor sit amet -
    - - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/eval_suppressed.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/eval_suppressed.xhtml deleted file mode 100644 index 0ad97d9b9b..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/eval_suppressed.xhtml +++ /dev/null @@ -1,9 +0,0 @@ -

    -

    -

    Me!

    -
    -

    All

    -
    -

    This

    - Should render -
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/filters.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/filters.xhtml deleted file mode 100644 index 32af24d365..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/filters.xhtml +++ /dev/null @@ -1,62 +0,0 @@ - -TESTING HAHAHAHA! -

    - -

    -This - Is - Plain - Text - %strong right? - #{not interpolated} - \3 - \#{also not} - \\ -

    -

    This pre is pretty deeply
          nested.
       Does interpolation work?
    -    This one is, too.
    Nested, that is.
    
    -

    -
      - -
    • a
    • - -
    • b
    • - -
    • c
    • - -
    • d
    • - -
    • e
    • - -
    • f
    • - -
    • g
    • - -
    • h
    • - -
    • i
    • - -
    • j
    • - - - -
    -
    178
    -Text! -Hello, World! -How are you doing today? -<div class="foo"> - <p>I think &mdash; or do I?</p> -</div> diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/helpers.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/helpers.xhtml deleted file mode 100644 index 8f1f8b0ff8..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/helpers.xhtml +++ /dev/null @@ -1,70 +0,0 @@ -&&&&&&&&&&& -
    -

    Title

    -

    - Woah this is really crazy - I mean wow, - man. -

    -
    -
    -

    Title

    -

    - Woah this is really crazy - I mean wow, - man. -

    -
    -
    -

    Title

    -

    - Woah this is really crazy - I mean wow, - man. -

    -
    -

    foo

    -

    reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong

    -
    -
    -
    -

    Big!

    -

    Small

    - -
    -
    -

    foo

    -

    bar

    -
    -
    - (parentheses!) -
    -*Not really -click -here. -

    baz

    -

    boom

    -foo -
  • google
  • -

    - foo -

    - bar -
    - boom - baz - boom, again -

    - - - - - -
    - strong! - data - - more_data -
    -
    -
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/helpful.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/helpful.xhtml deleted file mode 100644 index 042291d30d..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/helpful.xhtml +++ /dev/null @@ -1,10 +0,0 @@ -
    -

    Hello

    -
    World
    -
    -
    id
    -
    class
    -
    id class
    -
    boo
    -
    moo
    -
    foo
    \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/just_stuff.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/just_stuff.xhtml deleted file mode 100644 index e03404f0f1..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/just_stuff.xhtml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - -Boo! -Embedded? false! -Embedded? true! -Embedded? true! -Embedded? twice! true! -Embedded? one af"t"er another! -

    Embedded? false!

    -

    Embedded? true!

    -

    Embedded? true!

    -

    Embedded? twice! true!

    -

    Embedded? one af"t"er another!

    -stuff followed by whitespace -block with whitespace -

    - Escape - - character - %p foo - yee\ha -

    - - -

    class attribute should appear!

    -

    this attribute shouldn't appear

    - - - -testtest -
    - - -
    - - -
    - Nested content -
    -

    Blah

    -

    Blah

    -

    Blah

    -

    Blump

    -

    Whee

    -Woah inner quotes -

    -

    - - hello -

    - -
    - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/list.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/list.xhtml deleted file mode 100644 index 05d22018a7..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/list.xhtml +++ /dev/null @@ -1,12 +0,0 @@ -!Not a Doctype! -
      -
    • a
    • -
    • b
    • -
    • c
    • -
    • d
    • -
    • e
    • -
    • f
    • -
    • g
    • -
    • h
    • -
    • i
    • -
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/nuke_inner_whitespace.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/nuke_inner_whitespace.xhtml deleted file mode 100644 index 71d55d87ad..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/nuke_inner_whitespace.xhtml +++ /dev/null @@ -1,40 +0,0 @@ -

    - Foo -

    -

    - Foo -

    -

    - Foo - Bar -

    -

    - Foo - Bar -

    -

    - Foo - Bar -

    -

    - Foo - Bar -

    -

    -

    - Foo - Bar -
    -

    -

    -

    - Foo - Bar -
    -

    -

    - foo - - bar - -

    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/nuke_outer_whitespace.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/nuke_outer_whitespace.xhtml deleted file mode 100644 index a31cde3ae6..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/nuke_outer_whitespace.xhtml +++ /dev/null @@ -1,148 +0,0 @@ -

    -

    - Foo -

    -

    -

    -

    - Foo -

    -

    -

    -

    Foo

    -

    -

    -

    Foo

    -

    -

    -

    - Foo -

    -

    -

    -

    - Foo -

    -

    -

    -

    Foo

    -

    -

    -

    Foo

    -

    -

    -

    - Foo - Bar -

    -

    -

    -

    - Foo - Bar -

    -

    -

    -

    - Foo - Bar -

    -

    -

    -

    - Foo - Bar -

    -

    -

    -

    - foo - Foo - bar -

    -

    -

    -

    - foo - Foo - bar -

    -

    -

    -

    - fooFoobar -

    -

    -

    -

    - fooFoobar -

    -

    -

    -

    - foo - Foo - bar -

    -

    -

    -

    - foo - Foo - bar -

    -

    -

    -

    - fooFoobar -

    -

    -

    -

    - fooFoobar -

    -

    -

    -

    - foo - Foo - Bar - bar -

    -

    -

    -

    - foo - Foo - Bar - bar -

    -

    -

    -

    - foo - Foo - Bar - bar -

    -

    -

    -

    - foo - Foo - Bar - bar -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/original_engine.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/original_engine.xhtml deleted file mode 100644 index dd0e9f98b5..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/original_engine.xhtml +++ /dev/null @@ -1,20 +0,0 @@ - - - - Stop. haml time -
    -

    This is a title!

    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit

    -

    Cigarettes!

    -

    Man alive!

    -
      -
    • Slippers
    • -
    • Shoes
    • -
    • Bathrobe
    • -
    • Coffee
    • -
    -
    This is some text that's in a pre block!
    -      Let's see what happens when it's rendered! What about now, since we're on a new line?
    -
    - - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/partial_layout.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/partial_layout.xhtml deleted file mode 100644 index 53b96e3bee..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/partial_layout.xhtml +++ /dev/null @@ -1,5 +0,0 @@ -

    Partial layout used with for block:

    -
    -

    This is inside a partial layout

    -

    Some content within a layout

    -
    \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/partials.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/partials.xhtml deleted file mode 100644 index 12366ffa91..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/partials.xhtml +++ /dev/null @@ -1,21 +0,0 @@ -

    - @foo = - value one -

    -

    - @foo = - value two -

    -

    - @foo = - value two -

    -Toplevel? false -

    - @foo = - value three -

    -

    - @foo = - value three -

    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/render_layout.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/render_layout.xhtml deleted file mode 100644 index 9712bb5c5a..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/render_layout.xhtml +++ /dev/null @@ -1,3 +0,0 @@ -Before -During -After diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/silent_script.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/silent_script.xhtml deleted file mode 100644 index 76e90e0b64..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/silent_script.xhtml +++ /dev/null @@ -1,74 +0,0 @@ -
    -

    I can count!

    - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 -

    I know my ABCs!

    -
      -
    • a
    • -
    • b
    • -
    • c
    • -
    • d
    • -
    • e
    • -
    • f
    • -
    • g
    • -
    • h
    • -
    • i
    • -
    • j
    • -
    • k
    • -
    • l
    • -
    • m
    • -
    • n
    • -
    • o
    • -
    • p
    • -
    • q
    • -
    • r
    • -
    • s
    • -
    • t
    • -
    • u
    • -
    • v
    • -
    • w
    • -
    • x
    • -
    • y
    • -
    • z
    • -
    -

    I can catch errors!

    - Oh no! "undefined method `silly' for String:Class" happened! -

    - "false" is: - false -

    - Even! - Odd! - Even! - Odd! - Even! -
    -
    - foobar -
    -0 -1 -2 -3 -4 -
    -

    boom

    -
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/standard.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/standard.xhtml deleted file mode 100644 index 6897fc3039..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/standard.xhtml +++ /dev/null @@ -1,162 +0,0 @@ - - - - Hampton Catlin Is Totally Awesome - - - - -
    - Yes, ladies and gentileman. He is just that egotistical. - Fantastic! This should be multi-line output - The question is if this would translate! Ahah! - 20 -
    -
    Quotes should be loved! Just like people!
    - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - 39 - 40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 - 48 - 49 - 50 - 51 - 52 - 53 - 54 - 55 - 56 - 57 - 58 - 59 - 60 - 61 - 62 - 63 - 64 - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - 74 - 75 - 76 - 77 - 78 - 79 - 80 - 81 - 82 - 83 - 84 - 85 - 86 - 87 - 88 - 89 - 90 - 91 - 92 - 93 - 94 - 95 - 96 - 97 - 98 - 99 - 100 - 101 - 102 - 103 - 104 - 105 - 106 - 107 - 108 - 109 - 110 - 111 - 112 - 113 - 114 - 115 - 116 - 117 - 118 - 119 - Wow.| -

    - Holy cow multiline tags! A pipe (|) even! - PipesIgnored|PipesIgnored|PipesIgnored| - 1|2|3 -

    -
    - this shouldn't evaluate but now it should! -
    -
      -
    • a
    • -
    • b
    • -
    • c
    • -
    • d
    • -
    • e
    • -
    • f
    • -
    -
    with this text
    - foo - - - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/tag_parsing.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/tag_parsing.xhtml deleted file mode 100644 index e8178aa171..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/tag_parsing.xhtml +++ /dev/null @@ -1,23 +0,0 @@ -
    - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 -
    -
    -

    -
    a
    -
    b
    -
    c
    -
    d
    -
    e
    -
    f
    -
    g
    -
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/very_basic.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/very_basic.xhtml deleted file mode 100644 index 6a4cd25789..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/very_basic.xhtml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/whitespace_handling.xhtml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/whitespace_handling.xhtml deleted file mode 100644 index 11d04873e7..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/results/whitespace_handling.xhtml +++ /dev/null @@ -1,89 +0,0 @@ -
    -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    -
    - -
    - -
    -
    -
    - Foo bar -
    foo bar
    -
    foo
    bar
    -

    foo
    bar

    -

    - foo - bar -

    -
    -
    - 13 - - -
    -
    -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    -
    - -
    - -
    -
    -
    - Foo bar -
    foo bar
    -
    foo
    bar
    -

    foo
    bar

    -

    - foo - bar -

    -
                                                     ___
                                                  ,o88888
                                               ,o8888888'
                         ,:o:o:oooo.        ,8O88Pd8888"
                     ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
                   ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
                  , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
                 , ..:.::o:ooOoOO8O888O8O,COCOO"
                , . ..:.::o:ooOoOOOO8OOOOCOCO"
                 . ..:.::o:ooOoOoOO8O8OCCCC"o
                    . ..:.::o:ooooOoCoCCC"o:o
                    . ..:.::o:o:,cooooCo"oo:o:
                 `   . . ..:.:cocoooo"'o:o:::'
                 .`   . ..::ccccoc"'o:o:o:::'
                :.:.    ,c:cccc"':.:.:.:.:.'
              ..:.:"'`::::c:"'..:.:.:.:.:.'  http://www.chris.com/ASCII/
            ...:.'.:.::::"'    . . . . .'
           .. . ....:."' `   .  . . ''
         . . . ...."'
         .. . ."'     -hrr-
        .
    
    
                                                  It's a planet!
    %strong This shouldn't be bold!
    - This should! - -
    -
    - 13 -
    -
           __     ______        __               ______
    .----.|  |--.|__    |.----.|  |--..--------.|  __  |
    |  __||     ||__    ||  __||    < |        ||  __  |
    |____||__|__||______||____||__|__||__|__|__||______|
    -
    foo
    -bar
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/README.md b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/README.md deleted file mode 100644 index 95740c51c0..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# Haml Spec # - -Haml Spec provides a basic suite of tests for Haml interpreters. - -It is intented for developers who are creating or maintaining an implementation -of the [Haml](http://haml-lang.com) markup language. - -At the moment, there are test runners for the [original Haml](http://github.com/nex3/haml) -in Ruby, and for [Lua Haml](http://github.com/norman/lua-haml). Support for -other versions of Haml will be added if their developers/maintainers -are interested in using it. - -## The Tests ## - -The tests are kept in JSON format for portability across languages. Each test -is a JSON object with expected input, output, local variables and configuration -parameters (see below). The test suite only provides tests for features which -are portable, therefore no tests for script are provided, nor for external -filters such as :markdown or :textile. - -The one major exception to this are the tests for interpolation, which you may -need to modify with a regular expression to run under PHP or Perl, which -require a symbol before variable names. These tests are included despite being -less than 100% portable because interpolation is an important part of Haml and -can be tricky to implement. - -## Running the Tests ## - -### Ruby ### - -In order to make it as easy as possible for non-Ruby programmers to run the -Ruby Haml tests, the Ruby test runner uses test/unit, rather than something -fancier like Rspec. To run them you probably only need to install `haml`, and -possibly `ruby` if your platform doesn't come with it by default. If you're -using Ruby 1.8.x, you'll also need to install `json`: - - sudo gem install haml - # for Ruby 1.8.x; check using "ruby --version" if unsure - sudo gem install json - -Then, running the Ruby test suite is easy: - - ruby ruby_haml_test.rb - -### Lua ### - -The Lua test depends on [Telescope](http://telescope.luaforge.net/), -[jason4lua](http://json.luaforge.net/), and -[Lua Haml](http://github.com/norman/lua-haml). Install and -run `tsc lua_haml_spec.lua`. - -## Contributing ## - -### Getting it ### - -You can access the [Git repository](http://github.com/norman/haml-spec) at: - - git://github.com/norman/haml-spec.git - -Patches are *very* welcome, as are test runners for your Haml implementation. - -As long as any test you add run against Ruby Haml and are not redundant, I'll -be very happy to add them. - -### Test JSON format ### - - "test name" : { - "haml" : "haml input", - "html" : "expected html output", - "result" : "expected test result", - "locals" : "local vars", - "config" : "config params" - } - -* test name: This should be a *very* brief description of what's being tested. It can - be used by the test runners to name test methods, or to exclude certain tests from being - run. -* haml: The Haml code to be evaluated. Always required. -* html: The HTML output that should be generated. Required unless "result" is "error". -* result: Can be "pass" or "error". If it's absent, then "pass" is assumed. If it's "error", - then the goal of the test is to make sure that malformed Haml code generates an error. -* locals: An object containing local variables needed for the test. -* config: An object containing configuration parameters used to run the test. - The configuration parameters should be usable directly by Ruby's Haml with no - modification. If your implementation uses config parameters with different - names, you may need to process them to make them match your implementation. - If your implementation has options that do not exist in Ruby's Haml, then you - should add tests for this in your implementation's test rather than here. - -## License ## - - This project is released under the [WTFPL](http://sam.zoy.org/wtfpl/) in order - to be as usable as possible in any project, commercial or free. - -## Author ## - - [Norman Clarke](mailto:norman@njclarke.com) diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/lua_haml_spec.lua b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/lua_haml_spec.lua deleted file mode 100644 index 6cf4473508..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/lua_haml_spec.lua +++ /dev/null @@ -1,30 +0,0 @@ -require 'luarocks.require' -require 'json' -require 'telescope' -require 'haml' - -local function get_tests(filename) - local self = debug.getinfo(1).short_src - if self:match("/") then return "./" .. self:gsub("[^/]*%.lua$", "/" .. filename) - elseif self:match("\\") then return self:gsub("[^\\]*%.lua$", "\\" .. filename) - else return filename - end -end - -local fh = assert(io.open(get_tests("tests.json"))) -local input = fh:read '*a' -fh:close() - -local contexts = json.decode(input) - -describe("LuaHaml", function() - for context, expectations in pairs(contexts) do - describe("When handling " .. context, function() - for name, exp in pairs(expectations) do - it(string.format("should correctly render %s", name), function() - assert_equal(haml.render(exp.haml, exp.config or {}, exp.locals or {}), exp.html) - end) - end - end) - end -end) diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/ruby_haml_test.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/ruby_haml_test.rb deleted file mode 100644 index 444ba2dead..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/ruby_haml_test.rb +++ /dev/null @@ -1,19 +0,0 @@ -require "test/unit" -require "json" -require "haml" - -class HamlTest < Test::Unit::TestCase - contexts = JSON.parse(File.read(File.dirname(__FILE__) + "/tests.json")) - contexts.each do |context| - context[1].each do |name, test| - class_eval(<<-EOTEST) - def test_#{name.gsub(/\s+|[^a-zA-Z0-9_]/, "_")} - locals = Hash[*(#{test}["locals"] || {}).collect {|k, v| [k.to_sym, v] }.flatten] - options = Hash[*(#{test}["config"] || {}).collect {|k, v| [k.to_sym, v.to_sym] }.flatten] - engine = Haml::Engine.new(#{test}["haml"], options) - assert_equal(engine.render(Object.new, locals).chomp, #{test}["html"]) - end - EOTEST - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/tests.json b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/tests.json deleted file mode 100644 index e8f04542d9..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec/tests.json +++ /dev/null @@ -1,534 +0,0 @@ -{ - "headers" : { - - "an XHTML XML prolog" : { - "haml" : "!!! XML", - "html" : "" - }, - - "an XHTML default (transitional) doctype" : { - "haml" : "!!!", - "html" : "" - }, - - "an XHTML 1.1 doctype" : { - "haml" : "!!! 1.1", - "html" : "" - }, - - "an XHTML 1.2 mobile doctype" : { - "haml" : "!!! mobile", - "html" : "" - }, - - "an XHTML 1.1 basic doctype" : { - "haml" : "!!! basic", - "html" : "" - }, - - "an XHTML 1.0 frameset doctype" : { - "haml" : "!!! frameset", - "html" : "" - }, - - "an HTML 5 doctype with XHTML syntax" : { - "haml" : "!!! 5", - "html" : "" - }, - - "an HTML 5 XML prolog (silent)" : { - "haml" : "!!! XML", - "html" : "", - "config" : { - "format" : "html5" - } - }, - - "an HTML 5 doctype" : { - "haml" : "!!!", - "html" : "", - "config" : { - "format" : "html5" - } - }, - - "an HTML 4 XML prolog (silent)" : { - "haml" : "!!! XML", - "html" : "", - "config" : { - "format" : "html4" - } - }, - - "an HTML 4 default (transitional) doctype" : { - "haml" : "!!!", - "html" : "", - "config" : { - "format" : "html4" - } - }, - - "an HTML 4 frameset doctype" : { - "haml" : "!!! frameset", - "html" : "", - "config" : { - "format" : "html4" - } - }, - - "an HTML 4 strict doctype" : { - "haml" : "!!! strict", - "html" : "", - "config" : { - "format" : "html4" - } - } - - }, - - "basic Haml tags and CSS": { - - "a simple Haml tag" : { - "haml" : "%p", - "html" : "

    " - }, - - "a self-closing tag (XHTML)" : { - "haml" : "%meta", - "html" : "" - }, - - "a self-closing tag (HTML4)" : { - "haml" : "%meta", - "html" : "", - "config" : { - "format" : "html4" - } - }, - - "a self-closing tag (HTML5)" : { - "haml" : "%meta", - "html" : "", - "config" : { - "format" : "html5" - } - }, - - "a tag with a CSS class" : { - "haml" : "%p.class1", - "html" : "

    " - }, - - "a tag with multiple CSS classes" : { - "haml" : "%p.class1.class2", - "html" : "

    " - }, - - "a tag with a CSS id" : { - "haml" : "%p#id1", - "html" : "

    " - }, - - "a tag with multiple CSS id's" : { - "haml" : "%p#id1#id2", - "html" : "

    " - }, - - "a tag with a class followed by an id" : { - "haml" : "%p.class1#id1", - "html" : "

    " - }, - - "a tag with an id followed by a class" : { - "haml" : "%p#id1.class1", - "html" : "

    " - }, - - "an implicit div with a CSS id" : { - "haml" : "#id1", - "html" : "
    " - }, - - "an implicit div with a CSS class" : { - "haml" : ".class1", - "html" : "
    " - }, - - "multiple simple Haml tags" : { - "haml" : "%div\n %div\n %p", - "html" : "
    \n
    \n

    \n
    \n
    " - } - }, - - "tags with unusual HTML characters" : { - - "a tag with colons" : { - "haml" : "%ns:tag", - "html" : "" - }, - - "a tag with underscores" : { - "haml" : "%snake_case", - "html" : "" - }, - - "a tag with dashes" : { - "haml" : "%dashed-tag", - "html" : "" - }, - - "a tag with camelCase" : { - "haml" : "%camelCase", - "html" : "" - }, - - "a tag with PascalCase" : { - "haml" : "%PascalCase", - "html" : "" - } - }, - - "tags with unusual CSS identifiers" : { - - "an all-numeric class" : { - "haml" : ".123", - "html" : "
    " - }, - - "a class with underscores" : { - "haml" : ".__", - "html" : "
    " - }, - - "a class with dashes" : { - "haml" : ".--", - "html" : "
    " - } - - }, - - "tags with inline content" : { - - "a simple tag" : { - "haml" : "%p hello", - "html" : "

    hello

    " - }, - - "a tag with CSS" : { - "haml" : "%p.class1 hello", - "html" : "

    hello

    " - }, - - "multiple simple tags" : { - "haml" : "%div\n %div\n %p text", - "html" : "
    \n
    \n

    text

    \n
    \n
    " - } - }, - - "tags with nested content" : { - - "a simple tag" : { - "haml" : "%p\n hello", - "html" : "

    \n hello\n

    " - }, - - "a tag with CSS" : { - "haml" : "%p.class1\n hello", - "html" : "

    \n hello\n

    " - }, - - "multiple simple tags" : { - "haml" : "%div\n %div\n %p\n text", - "html" : "
    \n
    \n

    \n text\n

    \n
    \n
    " - } - - }, - - "tags with HTML-style attributes": { - - "one attribute" : { - "haml" : "%p(a='b')", - "html" : "

    " - }, - - "multiple attributes" : { - "haml" : "%p(a='b' c='d')", - "html" : "

    " - }, - - "attributes separated with newlines" : { - "haml" : "%p(a='b'\n c='d')", - "html" : "

    " - }, - - "an interpolated attribute" : { - "haml" : "%p(a=\"#{var}\")", - "html" : "

    ", - "locals" : { - "var" : "value" - } - }, - - "'class' as an attribute" : { - "haml" : "%p(class='class1')", - "html" : "

    " - }, - - "a tag with a CSS class and 'class' as an attribute" : { - "haml" : "%p.class2(class='class1')", - "html" : "

    " - }, - - "a tag with 'id' as an attribute" : { - "haml" : "%p(id='1')", - "html" : "

    " - }, - - "a tag with a CSS id and 'id' as an attribute" : { - "haml" : "%p#id(id='1')", - "html" : "

    " - }, - - "a tag with a variable attribute" : { - "haml" : "%p(class=var)", - "html" : "

    ", - "locals" : { - "var" : "hello" - } - }, - - "a tag with a CSS class and 'class' as a variable attribute" : { - "haml" : ".hello(class=var)", - "html" : "
    ", - "locals" : { - "var" : "world" - } - }, - - "a tag multiple CSS classes (sorted correctly)" : { - "haml" : ".z(class=var)", - "html" : "
    ", - "locals" : { - "var" : "a" - } - } - - }, - - "tags with Ruby-style attributes": { - - "one attribute" : { - "haml" : "%p{:a => 'b'}", - "html" : "

    " - }, - - "attributes hash with whitespace" : { - "haml" : "%p{ :a => 'b' }", - "html" : "

    " - }, - - "an interpolated attribute" : { - "haml" : "%p{:a =>\"#{var}\"}", - "html" : "

    ", - "locals" : { - "var" : "value" - } - }, - - "multiple attributes" : { - "haml" : "%p{ :a => 'b', 'c' => 'd' }", - "html" : "

    " - }, - - "attributes separated with newlines" : { - "haml" : "%p{ :a => 'b',\n 'c' => 'd' }", - "html" : "

    " - }, - - "'class' as an attribute" : { - "haml" : "%p{:class => 'class1'}", - "html" : "

    " - }, - - "a tag with a CSS class and 'class' as an attribute" : { - "haml" : "%p.class2{:class => 'class1'}", - "html" : "

    " - }, - - "a tag with 'id' as an attribute" : { - "haml" : "%p{:id => '1'}", - "html" : "

    " - }, - - "a tag with a CSS id and 'id' as an attribute" : { - "haml" : "%p#id{:id => '1'}", - "html" : "

    " - }, - - "a tag with a CSS id and a numeric 'id' as an attribute" : { - "haml" : "%p#id{:id => 1}", - "html" : "

    " - }, - - "a tag with a variable attribute" : { - "haml" : "%p{:class => var}", - "html" : "

    ", - "locals" : { - "var" : "hello" - } - }, - - "a tag with a CSS class and 'class' as a variable attribute" : { - "haml" : ".hello{:class => var}", - "html" : "
    ", - "locals" : { - "var" : "world" - } - }, - - "a tag multiple CSS classes (sorted correctly)" : { - "haml" : ".z{:class => var}", - "html" : "
    ", - "locals" : { - "var" : "a" - } - } - - }, - - "silent comments" : { - - "an inline comment" : { - "haml" : "-# hello", - "html" : "" - }, - - "a nested comment" : { - "haml" : "-#\n hello", - "html" : "" - } - - }, - - "markup comments" : { - - "an inline comment" : { - "haml" : "/ comment", - "html" : "" - }, - - "a nested comment" : { - "haml" : "/\n comment\n comment2", - "html" : "" - } - }, - - "conditional comments": { - "a conditional comment" : { - "haml" : "/[if IE]\n %p a", - "html" : "" - } - }, - - "internal filters": { - - "content in an 'escaped' filter" : { - "haml" : ":escaped\n <&\">", - "html" : "<&">" - }, - - "content in a 'preserve' filter" : { - "haml" : ":preserve\n hello\n\n%p", - "html" : "hello \n

    " - }, - - "content in a 'plain' filter" : { - "haml" : ":plain\n hello\n\n%p", - "html" : "hello\n

    " - }, - - "content in a 'javascript' filter" : { - "haml" : ":javascript\n a();\n%p", - "html" : "\n

    " - } - - }, - - "interpolation": { - - "interpolation inside inline content" : { - "haml" : "%p #{var}", - "html" : "

    value

    ", - "locals" : { - "var" : "value" - } - }, - - "no interpolation when escaped" : { - "haml" : "%p \\#{var}", - "html" : "

    #{var}

    " - }, - - "interpolation when the escape character is escaped" : { - "haml" : "%p \\\\#{var}", - "html" : "

    \\value

    ", - "locals" : { - "var" : "value" - } - }, - - "interpolation inside filtered content" : { - "haml" : ":plain\n #{var} interpolated: #{var}", - "html" : "value interpolated: value", - "locals" : { - "var" : "value" - } - } - - }, - - "HTML escaping" : { - - "code following '&='" : { - "haml" : "&= '<\"&>'", - "html" : "<"&>" - }, - - "code following '=' when escape_haml is set to true" : { - "haml" : "= '<\"&>'", - "html" : "<"&>", - "config" : { - "escape_html" : "true" - } - }, - - "code following '!=' when escape_haml is set to true" : { - "haml" : "!= '<\"&>'", - "html" : "<\"&>", - "config" : { - "escape_html" : "true" - } - } - - }, - - "Boolean attributes" : { - - "boolean attribute with XHTML" : { - "haml" : "%input(checked=true)", - "html" : "", - "config" : { - "format" : "xhtml" - } - }, - - "boolean attribute with HTML" : { - "haml" : "%input(checked=true)", - "html" : "", - "config" : { - "format" : "html5" - } - } - } - -} diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec_test.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec_test.rb deleted file mode 100755 index fe01685caf..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/spec_test.rb +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../test_helper' - -begin - require 'json' -rescue LoadError -end - -class SpecTest < Test::Unit::TestCase - spec_file = File.dirname(__FILE__) + '/spec/tests.json' - if !File.exists?(spec_file) - error = < true, :style => :compact) - end - - def create_base - vars = { 'article' => Article.new, 'foo' => 'value one' } - - unless Haml::Util.has?(:instance_method, ActionView::Base, :finder) - base = ActionView::Base.new(TEMPLATE_PATH, vars) - else - # Rails 2.1.0 - base = ActionView::Base.new([], vars) - base.finder.append_view_path(TEMPLATE_PATH) - end - - if Haml::Util.has?(:private_method, base, :evaluate_assigns) - # Rails < 3.0 - base.send(:evaluate_assigns) - elsif Haml::Util.has?(:private_method, base, :_evaluate_assigns_and_ivars) - # Rails 2.2 - base.send(:_evaluate_assigns_and_ivars) - end - - # This is needed by RJS in (at least) Rails 3 - base.instance_variable_set('@template', base) - - # This is used by form_for. - # It's usually provided by ActionController::Base. - def base.protect_against_forgery?; false; end - - # In Rails <= 2.1, a fake controller object was needed - # to provide the controller path. - if ActionPack::VERSION::MAJOR < 2 || - (ActionPack::VERSION::MAJOR == 2 && ActionPack::VERSION::MINOR < 2) - base.controller = DummyController.new - end - - base - end - - def render(text, opts = {}) - return @base.render(:inline => text, :type => :haml) if opts == :action_view - Haml::Engine.new(text, opts).to_html(@base) - end - - def load_result(name) - @result = '' - File.new(File.dirname(__FILE__) + "/results/#{name}.xhtml").each_line { |l| @result += l } - @result - end - - def assert_renders_correctly(name, &render_method) - old_options = Haml::Template.options.dup - Haml::Template.options[:escape_html] = false - if ActionPack::VERSION::MAJOR < 2 || - (ActionPack::VERSION::MAJOR == 2 && ActionPack::VERSION::MINOR < 2) - render_method ||= proc { |name| @base.render(name) } - else - render_method ||= proc { |name| @base.render(:file => name) } - end - - load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line| - message = "template: #{name}\nline: #{line}" - assert_equal(pair.first, pair.last, message) - end - rescue Haml::Util.av_template_class(:Error) => e - if e.message =~ /Can't run [\w:]+ filter; required (one of|file) ((?:'\w+'(?: or )?)+)(, but none were found| not found)/ - puts "\nCouldn't require #{$2}; skipping a test." - else - raise e - end - ensure - Haml::Template.options = old_options - end - - def test_empty_render_should_remain_empty - assert_equal('', render('')) - end - - TEMPLATES.each do |template| - define_method "test_template_should_render_correctly [template: #{template}] " do - assert_renders_correctly template - end - end - - def test_templates_should_render_correctly_with_render_proc - assert_renders_correctly("standard") do |name| - engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml")) - engine.render_proc(@base).call - end - end - - def test_templates_should_render_correctly_with_def_method - assert_renders_correctly("standard") do |name| - engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml")) - engine.def_method(@base, "render_standard") - @base.render_standard - end - end - - if ActionPack::VERSION::MAJOR < 3 - # Rails 3.0.0 deprecates the use of yield with a layout - # for calls to render :file - def test_action_view_templates_render_correctly - proc = lambda do - @base.content_for(:layout) {'Lorem ipsum dolor sit amet'} - assert_renders_correctly 'content_for_layout' - end - - if @base.respond_to?(:with_output_buffer) - @base.with_output_buffer("", &proc) - else - proc.call - end - end - end - - def test_instance_variables_should_work_inside_templates - @base.instance_variable_set("@content_for_layout", 'something') - assert_equal("

    something

    ", render("%p= @content_for_layout").chomp) - - @base.instance_eval("@author = 'Hampton Catlin'") - assert_equal("
    Hampton Catlin
    ", render(".author= @author").chomp) - - @base.instance_eval("@author = 'Hampton'") - assert_equal("Hampton", render("= @author").chomp) - - @base.instance_eval("@author = 'Catlin'") - assert_equal("Catlin", render("= @author").chomp) - end - - def test_instance_variables_should_work_inside_attributes - @base.instance_eval("@author = 'hcatlin'") - assert_equal("

    foo

    ", render("%p{:class => @author} foo").chomp) - end - - def test_template_renders_should_eval - assert_equal("2\n", render("= 1+1")) - end - - unless Haml::Util.ap_geq_3? - def test_form_for_error_return - assert_raise(Haml::Error) { render(< '' do |f| - Title: - = f.text_field :title - Body: - = f.text_field :body -HAML - end - - def test_form_tag_error_return - assert_raise(Haml::Error) { render(< true)) -

    -foo -baz -

    -HTML -%p - foo - -# Parenthesis required due to Rails 3.0 deprecation of block helpers - -# that return strings. - - (with_output_buffer do - bar - = "foo".gsub(/./) do |s| - - "flup" - - end; nil) - baz -HAML - end - - def test_exceptions_should_work_correctly - begin - render("- raise 'oops!'") - rescue Exception => e - assert_equal("oops!", e.message) - assert_match(/^\(haml\):1/, e.backtrace[0]) - else - assert false - end - - template = < e - assert_match(/^\(haml\):5/, e.backtrace[0]) - else - assert false - end - end - - if defined?(ActionView::OutputBuffer) && - Haml::Util.has?(:instance_method, ActionView::OutputBuffer, :append_if_string=) - def test_av_block_deprecation_warning - assert_warning(/^DEPRECATION WARNING: - style block helpers are deprecated\. Please use =\./) do - assert_equal <#{rails_form_opener} - Title: - - Body: - - -HTML -- form_for #{form_for_calling_convention(:article)}, :url => '' do |f| - Title: - = f.text_field :title - Body: - = f.text_field :body -HAML - end - end - end - - ## XSS Protection Tests - - # In order to enable these, either test against Rails 3.0 - # or test against Rails 2.2.5+ with the rails_xss plugin - # (http://github.com/NZKoz/rails_xss) in test/plugins. - if Haml::Util.rails_xss_safe? - def test_escape_html_option_set - assert Haml::Template.options[:escape_html] - end - - def test_xss_protection - assert_equal("Foo & Bar\n", render('= "Foo & Bar"', :action_view)) - end - - def test_xss_protection_with_safe_strings - assert_equal("Foo & Bar\n", render('= Haml::Util.html_safe("Foo & Bar")', :action_view)) - end - - def test_xss_protection_with_bang - assert_equal("Foo & Bar\n", render('!= "Foo & Bar"', :action_view)) - end - - def test_xss_protection_in_interpolation - assert_equal("Foo & Bar\n", render('Foo #{"&"} Bar', :action_view)) - end - - def test_xss_protection_with_bang_in_interpolation - assert_equal("Foo & Bar\n", render('! Foo #{"&"} Bar', :action_view)) - end - - def test_xss_protection_with_safe_strings_in_interpolation - assert_equal("Foo & Bar\n", render('Foo #{Haml::Util.html_safe("&")} Bar', :action_view)) - end - - def test_xss_protection_with_mixed_strings_in_interpolation - assert_equal("Foo & Bar & Baz\n", render('Foo #{Haml::Util.html_safe("&")} Bar #{"&"} Baz', :action_view)) - end - - def test_rendered_string_is_html_safe - assert(render("Foo").html_safe?) - end - - def test_rendered_string_is_html_safe_with_action_view - assert(render("Foo", :action_view).html_safe?) - end - - def test_xss_html_escaping_with_non_strings - assert_equal("4\n", render("= html_escape(4)")) - end - - def test_xss_protection_with_concat - assert_equal("Foo & Bar", render('- concat "Foo & Bar"', :action_view)) - end - - def test_xss_protection_with_concat_with_safe_string - assert_equal("Foo & Bar", render('- concat(Haml::Util.html_safe("Foo & Bar"))', :action_view)) - end - - if Haml::Util.has?(:instance_method, ActionView::Helpers::TextHelper, :safe_concat) - def test_xss_protection_with_safe_concat - assert_equal("Foo & Bar", render('- safe_concat "Foo & Bar"', :action_view)) - end - end - - ## Regression - - def test_xss_protection_with_nested_haml_tag - assert_equal(< -
      -
    • Content!
    • -
    - -HTML -- haml_tag :div do - - haml_tag :ul do - - haml_tag :li, "Content!" -HAML - end - - def test_xss_protection_with_form_for - assert_equal(<#{rails_form_opener} - Title: - - Body: - - -HTML -#{rails_block_helper_char} form_for #{form_for_calling_convention(:article)}, :url => '' do |f| - Title: - = f.text_field :title - Body: - = f.text_field :body -HAML - end - - def test_rjs - assert_equal(< 'haml/templates/av_partial_2' \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_1_ugly.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_1_ugly.haml deleted file mode 100644 index 73e0ca7ac3..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_1_ugly.haml +++ /dev/null @@ -1,9 +0,0 @@ -%h2 This is a pretty complicated partial -.partial - %p It has several nested partials, - %ul - - 5.times do - %li - %strong Partial: - - @nesting = 5 - = render :partial => 'haml/templates/av_partial_2_ugly' \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_2.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_2.haml deleted file mode 100644 index c8a313dfb0..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_2.haml +++ /dev/null @@ -1,5 +0,0 @@ -- @nesting -= 1 -.partial{:level => @nesting} - %h3 This is a crazy deep-nested partial. - %p== Nesting level #{@nesting} - = render :partial => 'haml/templates/av_partial_2' if @nesting > 0 \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_2_ugly.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_2_ugly.haml deleted file mode 100644 index 088a3c366f..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_av_partial_2_ugly.haml +++ /dev/null @@ -1,5 +0,0 @@ -- @nesting -= 1 -.partial{:level => @nesting} - %h3 This is a crazy deep-nested partial. - %p== Nesting level #{@nesting} - = render :partial => 'haml/templates/av_partial_2_ugly' if @nesting > 0 \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_layout.erb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_layout.erb deleted file mode 100644 index 91c839de1c..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_layout.erb +++ /dev/null @@ -1,3 +0,0 @@ -Before -<%= yield -%> -After diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_layout_for_partial.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_layout_for_partial.haml deleted file mode 100644 index 7cf538bd48..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_layout_for_partial.haml +++ /dev/null @@ -1,3 +0,0 @@ -.partial-layout - %h2 This is inside a partial layout - = yield \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_partial.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_partial.haml deleted file mode 100644 index 756b54bc14..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_partial.haml +++ /dev/null @@ -1,8 +0,0 @@ -%p - @foo = - = @foo -- @foo = 'value three' -== Toplevel? #{haml_buffer.toplevel?} -%p - @foo = - = @foo diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_text_area.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_text_area.haml deleted file mode 100644 index 896b9758c2..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/_text_area.haml +++ /dev/null @@ -1,3 +0,0 @@ -.text_area_test_area - ~ "" -= "" diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/action_view.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/action_view.haml deleted file mode 100644 index 5b9fa04f68..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/action_view.haml +++ /dev/null @@ -1,47 +0,0 @@ -!!! -%html{html_attrs} - %head - %title Hampton Catlin Is Totally Awesome - %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"} - %body - %h1 - This is very much like the standard template, - except that it has some ActionView-specific stuff. - It's only used for benchmarking. - .crazy_partials= render :partial => 'haml/templates/av_partial_1' - / You're In my house now! - .header - Yes, ladies and gentileman. He is just that egotistical. - Fantastic! This should be multi-line output - The question is if this would translate! Ahah! - = 1 + 9 + 8 + 2 #numbers should work and this should be ignored - #body= " Quotes should be loved! Just like people!" - - 120.times do |number| - - number - Wow.| - %p - = "Holy cow " + | - "multiline " + | - "tags! " + | - "A pipe (|) even!" | - = [1, 2, 3].collect { |n| "PipesIgnored|" } - = [1, 2, 3].collect { |n| | - n.to_s | - }.join("|") | - %div.silent - - foo = String.new - - foo << "this" - - foo << " shouldn't" - - foo << " evaluate" - = foo + " but now it should!" - -# Woah crap a comment! - - -# That was a line that shouldn't close everything. - %ul.really.cool - - ('a'..'f').each do |a| - %li= a - #combo.of_divs_with_underscore= @should_eval = "with this text" - = [ 104, 101, 108, 108, 111 ].map do |byte| - - byte.chr - .footer - %strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works" diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/action_view_ugly.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/action_view_ugly.haml deleted file mode 100644 index 5f0551ed9b..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/action_view_ugly.haml +++ /dev/null @@ -1,47 +0,0 @@ -!!! -%html{html_attrs} - %head - %title Hampton Catlin Is Totally Awesome - %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"} - %body - %h1 - This is very much like the standard template, - except that it has some ActionView-specific stuff. - It's only used for benchmarking. - .crazy_partials= render :partial => 'haml/templates/av_partial_1_ugly' - / You're In my house now! - .header - Yes, ladies and gentileman. He is just that egotistical. - Fantastic! This should be multi-line output - The question is if this would translate! Ahah! - = 1 + 9 + 8 + 2 #numbers should work and this should be ignored - #body= " Quotes should be loved! Just like people!" - - 120.times do |number| - - number - Wow.| - %p - = "Holy cow " + | - "multiline " + | - "tags! " + | - "A pipe (|) even!" | - = [1, 2, 3].collect { |n| "PipesIgnored|" } - = [1, 2, 3].collect { |n| | - n.to_s | - }.join("|") | - %div.silent - - foo = String.new - - foo << "this" - - foo << " shouldn't" - - foo << " evaluate" - = foo + " but now it should!" - -# Woah crap a comment! - - -# That was a line that shouldn't close everything. - %ul.really.cool - - ('a'..'f').each do |a| - %li= a - #combo.of_divs_with_underscore= @should_eval = "with this text" - = [ 104, 101, 108, 108, 111 ].map do |byte| - - byte.chr - .footer - %strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works" diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/breakage.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/breakage.haml deleted file mode 100644 index 57c1734143..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/breakage.haml +++ /dev/null @@ -1,8 +0,0 @@ -%p - %h1 Hello! - = "lots of lines" - - raise "Oh no!" - %p - this is after the exception - %strong yes it is! -ho ho ho. diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/content_for_layout.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/content_for_layout.haml deleted file mode 100644 index e9d7e6d66f..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/content_for_layout.haml +++ /dev/null @@ -1,8 +0,0 @@ -!!! -%html - %head - %body - #yieldy - = yield :layout - #nosym - = yield diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/eval_suppressed.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/eval_suppressed.haml deleted file mode 100644 index 1e3c0346b6..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/eval_suppressed.haml +++ /dev/null @@ -1,11 +0,0 @@ -= "not me!" -= "nor me!" -- haml_concat "not even me!" -%p= "NO!" -%p~ "UH-UH!" -%h1 Me! -#foo - %p#bar All - %br/ - %p.baz This - Should render diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/filters.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/filters.haml deleted file mode 100644 index dc5494d152..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/filters.haml +++ /dev/null @@ -1,66 +0,0 @@ -%style - - width = 5 + 17 - :sass - p - :border - :style dotted - :width #{width}px - :color #ff00ff - h1 - :font-weight normal - -:test - This - Should - Not - Print - -%p - :javascript - function newline(str) { - return "\n" + str; - } - -:plain - This - Is - Plain - Text - %strong right? - \#{not interpolated} - \\#{1 + 2} - \\\#{also not} - \\ - -- last = "noitalo" -%p - %pre - :preserve - This pre is pretty deeply - nested. - Does #{"interp" + last.reverse} work? - :preserve - This one is, too. - Nested, that is. - -- num = 10 -%ul - :erb - <% num.times do |c| %> -
  • <%= (c+97).chr %>
  • - <% end %> - <% res = 178 %> - -.res= res - -= "Text!" - -- var = "Hello" -:ruby - printf "%s, World!\n", var - print "How are you doing today?\n" - -:escaped -
    -

    I think — or do I?

    -
    diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/helpers.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/helpers.haml deleted file mode 100644 index c4be300b29..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/helpers.haml +++ /dev/null @@ -1,55 +0,0 @@ -= h("&&&&&&&&&&&") # This is an ActionView Helper... should load -- foo = capture do # This ActionView Helper is designed for ERB, but should work with haml - %div - %p.title Title - %p.text - Woah this is really crazy - I mean wow, - man. -- 3.times do - = foo -%p foo -- tab_up -%p reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong -- tab_down -.woah - #funky - = capture_haml do - %div - %h1 Big! - %p Small - / Invisible - = capture do - .dilly - %p foo - %h1 bar - = surround '(', ')' do - %strong parentheses! -= precede '*' do - %span.small Not really -click -= succeed '.' do - %a{:href=>"thing"} here -%p baz -- haml_buffer.tabulation = 10 -%p boom -- concat "foo\n" -- haml_buffer.tabulation = 0 -= list_of({:google => 'http://www.google.com'}) do |name, link| - %a{ :href => link }= name -%p - - haml_concat "foo" - %div - - haml_concat "bar" - - haml_concat "boom" - baz - - haml_concat "boom, again" -- haml_tag :table do - - haml_tag :tr do - - haml_tag :td, {:class => 'cell'} do - - haml_tag :strong, "strong!" - - haml_concat "data" - - haml_tag :td do - - haml_concat "more_data" -- haml_tag :hr -- haml_tag :div, '' diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/helpful.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/helpful.haml deleted file mode 100644 index 3e44a50db5..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/helpful.haml +++ /dev/null @@ -1,11 +0,0 @@ -%div[@article] - %h1= @article.title - %div= @article.body -#id[@article] id -.class[@article] class -#id.class[@article] id class -%div{:class => "article full"}[@article]= "boo" -%div{'class' => "article full"}[@article]= "moo" -%div.articleFull[@article]= "foo" -%span[@not_a_real_variable_and_will_be_nil] - Boo diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/just_stuff.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/just_stuff.haml deleted file mode 100644 index ec23ab2a51..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/just_stuff.haml +++ /dev/null @@ -1,85 +0,0 @@ -!!! XML -!!! XML ISO-8859-1 -!!! XML UtF-8 Foo bar -!!! -!!! 1.1 -!!! 1.1 Strict -!!! Strict foo bar -!!! FRAMESET -%strong{:apos => "Foo's bar!"} Boo! -== Embedded? false! -== Embedded? #{true}! -- embedded = true -== Embedded? #{embedded}! -== Embedded? #{"twice! #{true}"}! -== Embedded? #{"one"} af"t"er #{"another"}! -%p== Embedded? false! -%p== Embedded? #{true}! -- embedded = true -%p== Embedded? #{embedded}! -%p== Embedded? #{"twice! #{true}"}! -%p== Embedded? #{"one"} af"t"er #{"another"}! -= "stuff followed by whitespace" - -- if true - - %strong block with whitespace -%p - \Escape - \- character - \%p foo - \yee\ha -/ Short comment -/ - This is a block comment - cool, huh? - %strong there can even be sub-tags! - = "Or script!" --# Haml comment --# - Nested Haml comment - - raise 'dead' -%p{ :class => "" } class attribute should appear! -%p{ :gorbachev => nil } this attribute shouldn't appear -/[if lte IE6] conditional comment! -/[if gte IE7] - %p Block conditional comment - %div - %h1 Cool, eh? -/[if gte IE5.2] - Woah a period. -= "test" | - "test" | --# Hard tabs shouldn't throw errors. - -- case :foo -- when :bar - %br Blah -- when :foo - %br -- case :foo - - when :bar - %meta{ :foo => 'blah'} - - when :foo - %meta{ :foo => 'bar'} -%img -%hr -%link -%script Inline content -%br - Nested content -%p.foo{:class => true ? 'bar' : 'baz'}[@article] Blah -%p.foo{:class => false ? 'bar' : ''}[@article] Blah -%p.foo{:class => %w[bar baz]}[@article] Blah -%p.qux{:class => 'quux'}[@article] Blump -%p#foo{:id => %w[bar baz]}[@article] Whee -== #{"Woah inner quotes"} -%p.dynamic_quote{:quotes => "single '", :dyn => 1 + 2} -%p.dynamic_self_closing{:dyn => 1 + 2}/ -%body - :plain - hello - %div - - %img - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/list.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/list.haml deleted file mode 100644 index 40a80e6400..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/list.haml +++ /dev/null @@ -1,12 +0,0 @@ -!Not a Doctype! -%ul - %li a - %li b - %li c - %li d - %li e - %li f - %li g - %li h - %li i - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/nuke_inner_whitespace.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/nuke_inner_whitespace.haml deleted file mode 100644 index 8eebd417ee..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/nuke_inner_whitespace.haml +++ /dev/null @@ -1,32 +0,0 @@ -%p - %q< Foo -%p - %q{:a => 1 + 1}< Foo -%p - %q<= "Foo\nBar" -%p - %q{:a => 1 + 1}<= "Foo\nBar" -%p - %q< - Foo - Bar -%p - %q{:a => 1 + 1}< - Foo - Bar -%p - %q< - %div - Foo - Bar -%p - %q{:a => 1 + 1}< - %div - Foo - Bar - --# Regression test -%p - %q<= "foo" - %q{:a => 1 + 1} - bar diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/nuke_outer_whitespace.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/nuke_outer_whitespace.haml deleted file mode 100644 index 1e2a7f5f98..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/nuke_outer_whitespace.haml +++ /dev/null @@ -1,144 +0,0 @@ -%p - %p - %q> - Foo -%p - %p - %q{:a => 1 + 1}> - Foo -%p - %p - %q> Foo -%p - %p - %q{:a => 1 + 1}> Foo -%p - %p - %q> - = "Foo" -%p - %p - %q{:a => 1 + 1}> - = "Foo" -%p - %p - %q>= "Foo" -%p - %p - %q{:a => 1 + 1}>= "Foo" -%p - %p - %q> - = "Foo\nBar" -%p - %p - %q{:a => 1 + 1}> - = "Foo\nBar" -%p - %p - %q>= "Foo\nBar" -%p - %p - %q{:a => 1 + 1}>= "Foo\nBar" -%p - %p - - tab_up - foo - %q> - Foo - bar - - tab_down -%p - %p - - tab_up - foo - %q{:a => 1 + 1}> - Foo - bar - - tab_down -%p - %p - - tab_up - foo - %q> Foo - bar - - tab_down -%p - %p - - tab_up - foo - %q{:a => 1 + 1}> Foo - bar - - tab_down -%p - %p - - tab_up - foo - %q> - = "Foo" - bar - - tab_down -%p - %p - - tab_up - foo - %q{:a => 1 + 1}> - = "Foo" - bar - - tab_down -%p - %p - - tab_up - foo - %q>= "Foo" - bar - - tab_down -%p - %p - - tab_up - foo - %q{:a => 1 + 1}>= "Foo" - bar - - tab_down -%p - %p - - tab_up - foo - %q> - = "Foo\nBar" - bar - - tab_down -%p - %p - - tab_up - foo - %q{:a => 1 + 1}> - = "Foo\nBar" - bar - - tab_down -%p - %p - - tab_up - foo - %q>= "Foo\nBar" - bar - - tab_down -%p - %p - - tab_up - foo - %q{:a => 1 + 1}>= "Foo\nBar" - bar - - tab_down -%p - %p - %q> -%p - %p - %q>/ -%p - %p - %q{:a => 1 + 1}> -%p - %p - %q{:a => 1 + 1}>/ diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/original_engine.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/original_engine.haml deleted file mode 100644 index df31a5aa40..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/original_engine.haml +++ /dev/null @@ -1,17 +0,0 @@ -!!! -%html - %head - %title Stop. haml time - #content - %h1 This is a title! - %p Lorem ipsum dolor sit amet, consectetur adipisicing elit - %p{:class => 'foo'} Cigarettes! - %h2 Man alive! - %ul.things - %li Slippers - %li Shoes - %li Bathrobe - %li Coffee - %pre - This is some text that's in a pre block! - Let's see what happens when it's rendered! What about now, since we're on a new line? diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partial_layout.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partial_layout.haml deleted file mode 100644 index ab4999f040..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partial_layout.haml +++ /dev/null @@ -1,7 +0,0 @@ -%h1 Partial layout used with for block: -- if Haml::Util.ap_geq_3? - = render :layout => 'layout_for_partial.haml' do - %p Some content within a layout -- else - - render :layout => 'layout_for_partial.haml' do - %p Some content within a layout diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partialize.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partialize.haml deleted file mode 100644 index 327d90daa8..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partialize.haml +++ /dev/null @@ -1 +0,0 @@ -= render :file => "#{name}.haml" diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partials.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partials.haml deleted file mode 100644 index d74f4b45ba..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/partials.haml +++ /dev/null @@ -1,12 +0,0 @@ -- @foo = 'value one' -%p - @foo = - = @foo -- @foo = 'value two' -%p - @foo = - = @foo -= test_partial "partial" -%p - @foo = - = @foo diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/render_layout.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/render_layout.haml deleted file mode 100644 index 549742b986..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/render_layout.haml +++ /dev/null @@ -1,2 +0,0 @@ -= render :layout => 'layout' do - During diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/silent_script.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/silent_script.haml deleted file mode 100644 index 45199f0b6b..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/silent_script.haml +++ /dev/null @@ -1,40 +0,0 @@ -%div - %h1 I can count! - - (1..20).each do |i| - = i - %h1 I know my ABCs! - %ul - - ('a'..'z').each do |i| - %li= i - %h1 I can catch errors! - - begin - - String.silly - - rescue NameError => e - = "Oh no! \"#{e}\" happened!" - %p - "false" is: - - if false - = "true" - - else - = "false" - - if true - - 5.times do |i| - - if i % 2 == 1 - Odd! - - else - Even! - - else - = "This can't happen!" -- 13 | -.foo - %strong foobar -- 5.times | - do | - |a| | - %strong= a -.test - - "foo | - bar | - baz" | - - %p boom diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/standard.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/standard.haml deleted file mode 100644 index c1d48669d8..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/standard.haml +++ /dev/null @@ -1,43 +0,0 @@ -!!! -%html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en-US", "lang" => "en-US"} - %head - %title Hampton Catlin Is Totally Awesome - %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"} - %body - / You're In my house now! - .header - Yes, ladies and gentileman. He is just that egotistical. - Fantastic! This should be multi-line output - The question is if this would translate! Ahah! - = 1 + 9 + 8 + 2 #numbers should work and this should be ignored - #body= " Quotes should be loved! Just like people!" - - 120.times do |number| - = number - Wow.| - %p{:code => 1 + 2} - = "Holy cow " + | - "multiline " + | - "tags! " + | - "A pipe (|) even!" | - = [1, 2, 3].collect { |n| "PipesIgnored|" }.join - = [1, 2, 3].collect { |n| | - n.to_s | - }.join("|") | - - bar = 17 - %div.silent{:foo => bar} - - foo = String.new - - foo << "this" - - foo << " shouldn't" - - foo << " evaluate" - = foo + " but now it should!" - -# Woah crap a comment! - - -# That was a line that shouldn't close everything. - %ul.really.cool - - ('a'..'f').each do |a| - %li= a - #combo.of_divs_with_underscore= @should_eval = "with this text" - = "foo".each_line do |line| - - nil - .footer - %strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works" diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/standard_ugly.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/standard_ugly.haml deleted file mode 100644 index c1d48669d8..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/standard_ugly.haml +++ /dev/null @@ -1,43 +0,0 @@ -!!! -%html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en-US", "lang" => "en-US"} - %head - %title Hampton Catlin Is Totally Awesome - %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"} - %body - / You're In my house now! - .header - Yes, ladies and gentileman. He is just that egotistical. - Fantastic! This should be multi-line output - The question is if this would translate! Ahah! - = 1 + 9 + 8 + 2 #numbers should work and this should be ignored - #body= " Quotes should be loved! Just like people!" - - 120.times do |number| - = number - Wow.| - %p{:code => 1 + 2} - = "Holy cow " + | - "multiline " + | - "tags! " + | - "A pipe (|) even!" | - = [1, 2, 3].collect { |n| "PipesIgnored|" }.join - = [1, 2, 3].collect { |n| | - n.to_s | - }.join("|") | - - bar = 17 - %div.silent{:foo => bar} - - foo = String.new - - foo << "this" - - foo << " shouldn't" - - foo << " evaluate" - = foo + " but now it should!" - -# Woah crap a comment! - - -# That was a line that shouldn't close everything. - %ul.really.cool - - ('a'..'f').each do |a| - %li= a - #combo.of_divs_with_underscore= @should_eval = "with this text" - = "foo".each_line do |line| - - nil - .footer - %strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works" diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/tag_parsing.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/tag_parsing.haml deleted file mode 100644 index f142ebbd2c..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/tag_parsing.haml +++ /dev/null @@ -1,21 +0,0 @@ -%div.tags - %foo 1 - %FOO 2 - %fooBAR 3 - %fooBar 4 - %foo_bar 5 - %foo-bar 6 - %foo:bar 7 - %foo.bar 8 - %fooBAr_baz:boom_bar 9 - %foo13 10 - %foo2u 11 -%div.classes - %p.foo.bar#baz#boom - .fooBar a - .foo-bar b - .foo_bar c - .FOOBAR d - .foo16 e - .123 f - .foo2u g diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/very_basic.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/very_basic.haml deleted file mode 100644 index 93396b9615..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/very_basic.haml +++ /dev/null @@ -1,4 +0,0 @@ -!!! -%html - %head - %body diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/whitespace_handling.haml b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/whitespace_handling.haml deleted file mode 100644 index f459e75fae..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/templates/whitespace_handling.haml +++ /dev/null @@ -1,87 +0,0 @@ -#whitespace_test - = test_partial "text_area", :value => "Oneline" - = test_partial "text_area", :value => "Two\nlines" - ~ test_partial "text_area", :value => "Oneline" - ~ test_partial "text_area", :value => "Two\nlines" - #flattened~ test_partial "text_area", :value => "Two\nlines" -.hithere - ~ "Foo bar" - ~ "
    foo bar
    " - ~ "
    foo\nbar
    " - %p~ "
    foo\nbar
    " - %p~ "foo\nbar" -.foo - ~ 13 - ~ "".each_line do |l| - - haml_concat l.strip -#whitespace_test - = test_partial "text_area", :value => "Oneline" - = test_partial "text_area", :value => "Two\nlines" - = find_and_preserve test_partial("text_area", :value => "Oneline") - = find_and_preserve test_partial("text_area", :value => "Two\nlines") - #flattened= find_and_preserve test_partial("text_area", :value => "Two\nlines") -.hithere - = find_and_preserve("Foo bar") - = find_and_preserve("
    foo bar
    ") - = find_and_preserve("
    foo\nbar
    ") - %p= find_and_preserve("
    foo\nbar
    ") - %p= find_and_preserve("foo\nbar") - %pre - :preserve - ___ - ,o88888 - ,o8888888' - ,:o:o:oooo. ,8O88Pd8888" - ,.::.::o:ooooOoOoO. ,oO8O8Pd888'" - ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O" - , ..:.::o:ooOoOOOO8OOOOo.FdO8O8" - , ..:.::o:ooOoOO8O888O8O,COCOO" - , . ..:.::o:ooOoOOOO8OOOOCOCO" - . ..:.::o:ooOoOoOO8O8OCCCC"o - . ..:.::o:ooooOoCoCCC"o:o - . ..:.::o:o:,cooooCo"oo:o: - ` . . ..:.:cocoooo"'o:o:::' - .` . ..::ccccoc"'o:o:o:::' - :.:. ,c:cccc"':.:.:.:.:.' - ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/ - ...:.'.:.::::"' . . . . .' - .. . ....:."' ` . . . '' - . . . ...."' - .. . ."' -hrr- - . - - - It's a planet! - %strong This shouldn't be bold! - %strong This should! - %textarea - :preserve - ___ ___ ___ ___ - /\__\ /\ \ /\__\ /\__\ - /:/ / /::\ \ /::| | /:/ / - /:/__/ /:/\:\ \ /:|:| | /:/ / - /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / - /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ - \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ - \::/ / \::/ / /:/ / \:\ \ - /:/ / /:/ / /:/ / \:\ \ - /:/ / /:/ / /:/ / \:\__\ - \/__/ \/__/ \/__/ \/__/ - - Many - thanks - to - http://www.network-science.de/ascii/ - %strong indeed! -.foo - = find_and_preserve(13) -%pre - :preserve - __ ______ __ ______ - .----.| |--.|__ |.----.| |--..--------.| __ | - | __|| ||__ || __|| < | || __ | - |____||__|__||______||____||__|__||__|__|__||______| -%pre - :preserve - foo - bar diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/util_test.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/util_test.rb deleted file mode 100755 index fdcdee74c3..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/haml/util_test.rb +++ /dev/null @@ -1,300 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../test_helper' -require 'pathname' - -class UtilTest < Test::Unit::TestCase - include Haml::Util - - class Dumpable - attr_reader :arr - def initialize; @arr = []; end - def _before_dump; @arr << :before; end - def _after_dump; @arr << :after; end - def _around_dump - @arr << :around_before - yield - @arr << :around_after - end - def _after_load; @arr << :loaded; end - end - - def test_scope - assert(File.exist?(scope("Rakefile"))) - end - - def test_to_hash - assert_equal({ - :foo => 1, - :bar => 2, - :baz => 3 - }, to_hash([[:foo, 1], [:bar, 2], [:baz, 3]])) - end - - def test_map_keys - assert_equal({ - "foo" => 1, - "bar" => 2, - "baz" => 3 - }, map_keys({:foo => 1, :bar => 2, :baz => 3}) {|k| k.to_s}) - end - - def test_map_vals - assert_equal({ - :foo => "1", - :bar => "2", - :baz => "3" - }, map_vals({:foo => 1, :bar => 2, :baz => 3}) {|k| k.to_s}) - end - - def test_map_hash - assert_equal({ - "foo" => "1", - "bar" => "2", - "baz" => "3" - }, map_hash({:foo => 1, :bar => 2, :baz => 3}) {|k, v| [k.to_s, v.to_s]}) - end - - def test_powerset - return unless Set[Set[]] == Set[Set[]] # There's a bug in Ruby 1.8.6 that breaks nested set equality - assert_equal([[].to_set].to_set, - powerset([])) - assert_equal([[].to_set, [1].to_set].to_set, - powerset([1])) - assert_equal([[].to_set, [1].to_set, [2].to_set, [1, 2].to_set].to_set, - powerset([1, 2])) - assert_equal([[].to_set, [1].to_set, [2].to_set, [3].to_set, - [1, 2].to_set, [2, 3].to_set, [1, 3].to_set, [1, 2, 3].to_set].to_set, - powerset([1, 2, 3])) - end - - def test_restrict - assert_equal(0.5, restrict(0.5, 0..1)) - assert_equal(1, restrict(2, 0..1)) - assert_equal(1.3, restrict(2, 0..1.3)) - assert_equal(0, restrict(-1, 0..1)) - end - - def test_merge_adjacent_strings - assert_equal(["foo bar baz", :bang, "biz bop", 12], - merge_adjacent_strings(["foo ", "bar ", "baz", :bang, "biz", " bop", 12])) - str = "foo" - assert_equal(["foo foo foo", :bang, "foo foo", 12], - merge_adjacent_strings([str, " ", str, " ", str, :bang, str, " ", str, 12])) - end - - def test_intersperse - assert_equal(["foo", " ", "bar", " ", "baz"], - intersperse(%w[foo bar baz], " ")) - assert_equal([], intersperse([], " ")) - end - - def test_substitute - assert_equal(["foo", "bar", "baz", 3, 4], - substitute([1, 2, 3, 4], [1, 2], ["foo", "bar", "baz"])) - assert_equal([1, "foo", "bar", "baz", 4], - substitute([1, 2, 3, 4], [2, 3], ["foo", "bar", "baz"])) - assert_equal([1, 2, "foo", "bar", "baz"], - substitute([1, 2, 3, 4], [3, 4], ["foo", "bar", "baz"])) - - assert_equal([1, "foo", "bar", "baz", 2, 3, 4], - substitute([1, 2, 2, 2, 3, 4], [2, 2], ["foo", "bar", "baz"])) - end - - def test_strip_string_array - assert_equal(["foo ", " bar ", " baz"], - strip_string_array([" foo ", " bar ", " baz "])) - assert_equal([:foo, " bar ", " baz"], - strip_string_array([:foo, " bar ", " baz "])) - assert_equal(["foo ", " bar ", :baz], - strip_string_array([" foo ", " bar ", :baz])) - end - - def test_paths - assert_equal([[1, 3, 5], [2, 3, 5], [1, 4, 5], [2, 4, 5]], - paths([[1, 2], [3, 4], [5]])) - assert_equal([[]], paths([])) - assert_equal([[1, 2, 3]], paths([[1], [2], [3]])) - end - - def test_lcs - assert_equal([1, 2, 3], lcs([1, 2, 3], [1, 2, 3])) - assert_equal([], lcs([], [1, 2, 3])) - assert_equal([], lcs([1, 2, 3], [])) - assert_equal([1, 2, 3], lcs([5, 1, 4, 2, 3, 17], [0, 0, 1, 2, 6, 3])) - - assert_equal([1], lcs([1, 2, 3, 4], [4, 3, 2, 1])) - assert_equal([1, 2], lcs([1, 2, 3, 4], [3, 4, 1, 2])) - end - - def test_lcs_with_block - assert_equal(["1", "2", "3"], - lcs([1, 4, 2, 5, 3], [1, 2, 3]) {|a, b| a == b && a.to_s}) - assert_equal([-4, 2, 8], - lcs([-5, 3, 2, 8], [-4, 1, 8]) {|a, b| (a - b).abs <= 1 && [a, b].max}) - end - - def test_silence_warnings - old_stderr, $stderr = $stderr, StringIO.new - warn "Out" - assert_equal("Out\n", $stderr.string) - silence_warnings {warn "In"} - assert_equal("Out\n", $stderr.string) - ensure - $stderr = old_stderr - end - - def test_haml_warn - assert_warning("Foo!") {haml_warn "Foo!"} - end - - def test_silence_haml_warnings - old_stderr, $stderr = $stderr, StringIO.new - silence_haml_warnings {warn "Out"} - assert_equal("Out\n", $stderr.string) - silence_haml_warnings {haml_warn "In"} - assert_equal("Out\n", $stderr.string) - ensure - $stderr = old_stderr - end - - def test_has - assert(has?(:instance_method, String, :chomp!)) - assert(has?(:private_instance_method, Haml::Engine, :set_locals)) - end - - def test_enum_with_index - assert_equal(%w[foo0 bar1 baz2], - enum_with_index(%w[foo bar baz]).map {|s, i| "#{s}#{i}"}) - end - - def test_enum_cons - assert_equal(%w[foobar barbaz], - enum_cons(%w[foo bar baz], 2).map {|s1, s2| "#{s1}#{s2}"}) - end - - def test_ord - assert_equal(102, ord("f")) - assert_equal(98, ord("bar")) - end - - def test_flatten - assert_equal([1, 2, 3], flatten([1, 2, 3], 0)) - assert_equal([1, 2, 3], flatten([1, 2, 3], 1)) - assert_equal([1, 2, 3], flatten([1, 2, 3], 2)) - - assert_equal([[1, 2], 3], flatten([[1, 2], 3], 0)) - assert_equal([1, 2, 3], flatten([[1, 2], 3], 1)) - assert_equal([1, 2, 3], flatten([[1, 2], 3], 2)) - - assert_equal([[[1], 2], [3], 4], flatten([[[1], 2], [3], 4], 0)) - assert_equal([[1], 2, 3, 4], flatten([[[1], 2], [3], 4], 1)) - assert_equal([1, 2, 3, 4], flatten([[[1], 2], [3], 4], 2)) - end - - def test_set_hash - assert(set_hash(Set[1, 2, 3]) == set_hash(Set[3, 2, 1])) - assert(set_hash(Set[1, 2, 3]) == set_hash(Set[1, 2, 3])) - - s1 = Set[] - s1 << 1 - s1 << 2 - s1 << 3 - s2 = Set[] - s2 << 3 - s2 << 2 - s2 << 1 - assert(set_hash(s1) == set_hash(s2)) - end - - def test_set_eql - assert(set_eql?(Set[1, 2, 3], Set[3, 2, 1])) - assert(set_eql?(Set[1, 2, 3], Set[1, 2, 3])) - - s1 = Set[] - s1 << 1 - s1 << 2 - s1 << 3 - s2 = Set[] - s2 << 3 - s2 << 2 - s2 << 1 - assert(set_eql?(s1, s2)) - end - - def test_caller_info - assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle'")) - assert_equal(["/tmp/foo.rb", 12, nil], caller_info("/tmp/foo.rb:12")) - assert_equal(["(haml)", 12, "blah"], caller_info("(haml):12: in `blah'")) - assert_equal(["", 12, "boop"], caller_info(":12: in `boop'")) - assert_equal(["/tmp/foo.rb", -12, "fizzle"], caller_info("/tmp/foo.rb:-12: in `fizzle'")) - assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle {}'")) - end - - def test_version_gt - assert_version_gt("2.0.0", "1.0.0") - assert_version_gt("1.1.0", "1.0.0") - assert_version_gt("1.0.1", "1.0.0") - assert_version_gt("1.0.0", "1.0.0.rc") - assert_version_gt("1.0.0.1", "1.0.0.rc") - assert_version_gt("1.0.0.rc", "0.9.9") - assert_version_gt("1.0.0.beta", "1.0.0.alpha") - - assert_version_eq("1.0.0", "1.0.0") - assert_version_eq("1.0.0", "1.0.0.0") - end - - def assert_version_gt(v1, v2) - #assert(version_gt(v1, v2), "Expected #{v1} > #{v2}") - assert(!version_gt(v2, v1), "Expected #{v2} < #{v1}") - end - - def assert_version_eq(v1, v2) - assert(!version_gt(v1, v2), "Expected #{v1} = #{v2}") - assert(!version_gt(v2, v1), "Expected #{v2} = #{v1}") - end - - def test_dump_and_load - obj = Dumpable.new - data = dump(obj) - assert_equal([:before, :around_before, :around_after, :after], obj.arr) - obj2 = load(data) - assert_equal([:before, :around_before, :loaded], obj2.arr) - end - - class FooBar - def foo - Haml::Util.abstract(self) - end - end - - def test_abstract - assert_raise_message(NotImplementedError, - "UtilTest::FooBar must implement #foo") {FooBar.new.foo} - end - - def test_def_static_method - klass = Class.new - def_static_method(klass, :static_method, [:arg1, :arg2], - :sarg1, :sarg2, <and<% else %>but never<% end %> " << arg2 - - <% if sarg2 %> - s << "." - <% end %> -RUBY - c = klass.new - assert_equal("Always brush your teeth and comb your hair.", - c.send(static_method_name(:static_method, true, true), - "brush your teeth", "comb your hair")) - assert_equal("Always brush your teeth and comb your hair", - c.send(static_method_name(:static_method, true, false), - "brush your teeth", "comb your hair")) - assert_equal("Always brush your teeth but never play with fire.", - c.send(static_method_name(:static_method, false, true), - "brush your teeth", "play with fire")) - assert_equal("Always brush your teeth but never play with fire", - c.send(static_method_name(:static_method, false, false), - "brush your teeth", "play with fire")) - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/linked_rails.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/linked_rails.rb deleted file mode 100644 index 56f3bb8201..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/linked_rails.rb +++ /dev/null @@ -1,42 +0,0 @@ -# allows testing with edge Rails by creating a test/rails symlink -linked_rails = File.dirname(__FILE__) + '/rails' - -if File.exists?(linked_rails) && !$:.include?(linked_rails + '/activesupport/lib') - puts "[ using linked Rails ]" - $:.unshift linked_rails + '/activesupport/lib' - $:.unshift linked_rails + '/actionpack/lib' - $:.unshift linked_rails + '/railties/lib' -end -require 'rubygems' -require 'action_controller' -require 'action_view' - -begin - # Necessary for Rails 3 - require 'rails' -rescue LoadError - # Necessary for Rails 2.3.7 - require 'initializer' -rescue LoadError -end - -if defined?(Rails::Application) # Rails 3 - class TestApp < Rails::Application - config.root = File.join(File.dirname(__FILE__), "../..") - end - Rails.application = TestApp -elsif defined?(RAILS_ROOT) - RAILS_ROOT.replace(File.join(File.dirname(__FILE__), "../..")) -else - RAILS_ROOT = File.join(File.dirname(__FILE__), "../..") -end - -ActionController::Base.logger = Logger.new(nil) - -# Load plugins from test/plugins. -# This will only work with very basic plugins, -# since we don't want to load the entirety of Rails. -Dir[File.dirname(__FILE__) + '/plugins/*'].each do |plugin| - $: << plugin + '/lib' - eval(File.read(plugin + '/init.rb')) -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/test_helper.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/test/test_helper.rb deleted file mode 100644 index c8c31d6c13..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/test/test_helper.rb +++ /dev/null @@ -1,75 +0,0 @@ -lib_dir = File.dirname(__FILE__) + '/../lib' -require File.dirname(__FILE__) + '/linked_rails' - -require 'test/unit' -require 'fileutils' -$:.unshift lib_dir unless $:.include?(lib_dir) -require 'haml' - -require 'haml/template' -Haml::Template.options[:ugly] = false -Haml::Template.options[:format] = :xhtml - -class Test::Unit::TestCase - def assert_warning(message) - the_real_stderr, $stderr = $stderr, StringIO.new - yield - - if message.is_a?(Regexp) - assert_match message, $stderr.string.strip - else - assert_equal message.strip, $stderr.string.strip - end - ensure - $stderr = the_real_stderr - end - - def silence_warnings(&block) - Haml::Util.silence_warnings(&block) - end - - def rails_block_helper_char - return '=' if Haml::Util.ap_geq_3? - return '-' - end - - def form_for_calling_convention(name) - return "@#{name}, :as => :#{name}, :html => {:class => nil, :id => nil}" if Haml::Util.ap_geq_3? - return ":#{name}, @#{name}" - end - - def rails_form_attr - return 'accept-charset="UTF-8" ' if Haml::Util.ap_geq?("3.0.0.rc") - return '' - end - - def rails_form_opener - return '' unless Haml::Util.ap_geq?("3.0.0.rc") - if Haml::Util.ap_geq?("3.0.0.rc2") - encoding = 'utf8' - char = '✓' - else - encoding = '_snowman' - char = '☃' - end - return '
    ' - end - - def assert_raise_message(klass, message) - yield - rescue Exception => e - assert_instance_of(klass, e) - assert_equal(message, e.message) - else - flunk "Expected exception #{klass}, none raised" - end - - def assert_raise_line(line) - yield - rescue Sass::SyntaxError => e - assert_equal(line, e.sass_line) - else - flunk "Expected exception on line #{line}, none raised" - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/CONTRIBUTING b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/CONTRIBUTING deleted file mode 100644 index be466d3920..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/CONTRIBUTING +++ /dev/null @@ -1,3 +0,0 @@ -Contributions are welcomed. Please see the following sites for guidelines: - - http://sass-lang.com/development.html#contributing diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/MIT-LICENSE b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/MIT-LICENSE deleted file mode 100644 index 68b7aefb1a..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/README.md b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/README.md deleted file mode 100644 index 0daa35d7b3..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/README.md +++ /dev/null @@ -1,201 +0,0 @@ -# Sass - -**Sass makes CSS fun again**. Sass is an extension of CSS3, -adding nested rules, variables, mixins, selector inheritance, and more. -It's translated to well-formatted, standard CSS -using the command line tool or a web-framework plugin. - -Sass has two syntaxes. The new main syntax (as of Sass 3) -is known as "SCSS" (for "Sassy CSS"), -and is a superset of CSS3's syntax. -This means that every valid CSS3 stylesheet is valid SCSS as well. -SCSS files use the extension `.scss`. - -The second, older syntax is known as the indented syntax (or just "Sass"). -Inspired by Haml's terseness, it's intended for people -who prefer conciseness over similarity to CSS. -Instead of brackets and semicolons, -it uses the indentation of lines to specify blocks. -Although no longer the primary syntax, -the indented syntax will continue to be supported. -Files in the indented syntax use the extension `.sass`. - -## Using - -Sass can be used from the command line -or as part of a web framework. -The first step is to install the gem: - - gem install sass - -After you convert some CSS to Sass, you can run - - sass style.scss - -to compile it back to CSS. -For more information on these commands, check out - - sass --help - -To install Sass in Rails 2, -just add `config.gem "sass"` to `config/environment.rb`. -In Rails 3, add `gem "sass"` to your Gemfile instead. -`.sass` or `.scss` files should be placed in `public/stylesheets/sass`, -where they'll be automatically compiled -to corresponding CSS files in `public/stylesheets` when needed -(the Sass template directory is customizable... -see [the Sass reference](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#template_location-option) for details). - -Sass can also be used with any Rack-enabled web framework. -To do so, just add - - require 'sass/plugin/rack' - use Sass::Plugin::Rack - -to `config.ru`. -Then any Sass files in `public/stylesheets/sass` -will be compiled CSS files in `public/stylesheets` on every request. - -To use Sass programatically, -check out the [YARD documentation](http://sass-lang.com/docs/yardoc/). - -## Formatting - -Sass is an extension of CSS -that adds power and elegance to the basic language. -It allows you to use [variables][vars], [nested rules][nested], -[mixins][mixins], [inline imports][imports], -and more, all with a fully CSS-compatible syntax. -Sass helps keep large stylesheets well-organized, -and get small stylesheets up and running quickly, -particularly with the help of -[the Compass style library](http://compass-style.org). - -[vars]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#variables_ -[nested]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#nested_rules_ -[mixins]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins -[imports]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#import - -Sass has two syntaxes. -The one presented here, known as "SCSS" (for "Sassy CSS"), -is fully CSS-compatible. -The other (older) syntax, known as the indented syntax or just "Sass", -is whitespace-sensitive and indentation-based. -For more information, see the [reference documentation][syntax]. - -[syntax]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#syntax - -To run the following examples and see the CSS they produce, -put them in a file called `test.scss` and run `sass test.scss`. - -### Nesting - -Sass avoids repetition by nesting selectors within one another. -The same thing works for properties. - - table.hl { - margin: 2em 0; - td.ln { text-align: right; } - } - - li { - font: { - family: serif; - weight: bold; - size: 1.2em; - } - } - -### Variables - -Use the same color all over the place? -Need to do some math with height and width and text size? -Sass supports variables, math operations, and many useful functions. - - $blue: #3bbfce; - $margin: 16px; - - .content_navigation { - border-color: $blue; - color: darken($blue, 10%); - } - - .border { - padding: $margin / 2; - margin: $margin / 2; - border-color: $blue; - } - -### Mixins - -Even more powerful than variables, -mixins allow you to re-use whole chunks of CSS, -properties or selectors. -You can even give them arguments. - - @mixin table-scaffolding { - th { - text-align: center; - font-weight: bold; - } - td, th { padding: 2px; } - } - - @mixin left($dist) { - float: left; - margin-left: $dist; - } - - #data { - @include left(10px); - @include table-scaffolding; - } - -A comprehensive list of features is available -in the [Sass reference](http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html). - -## Executables - -The Sass gem includes several executables that are useful -for dealing with Sass from the command line. - -### `sass` - -The `sass` executable transforms a source Sass file into CSS. -See `sass --help` for further information and options. - -### `sass-convert` - -The `sass-convert` executable converts between CSS, Sass, and SCSS. -When converting from CSS to Sass or SCSS, -nesting is applied where appropriate. -See `sass-convert --help` for further information and options. - -## Authors - -Sass was envisioned by [Hampton Catlin](http://hamptoncatlin.com) (hcatlin). -However, Hampton doesn't even know his way around the code anymore and now -occasionally consults on the language issues. Hampton lives in Jacksonville, -Florida and is the lead mobile developer for Wikimedia. - -[Nathan Weizenbaum](http://nex-3.com) is the primary developer and architect of -Sass. His hard work has kept the project alive by endlessly answering forum -posts, fixing bugs, refactoring, finding speed improvements, writing -documentation, implementing new features, and getting Hampton coffee (a fitting -task for a boy-genius). Nathan lives in Seattle, Washington and while not being -a student at the University of Washington or working at an internship, he -consults for Unspace Interactive. - -[Chris Eppstein](http://acts-as-architect.blogspot.com) is a core contributor to -Sass and the creator of Compass, the first Sass-based framework. Chris focuses -on making Sass more powerful, easy to use, and on ways to speed its adoption -through the web development community. Chris lives in San Jose, California with -his wife and daughter. He is the Software Architect for -[Caring.com](http://caring.com), a website devoted to the 34 Million caregivers -whose parents are sick or elderly, that uses Haml and Sass. - -If you use this software, you must pay Hampton a compliment. And -buy Nathan some jelly beans. Maybe pet a kitten. Yeah. Pet that kitty. - -Beyond that, the implementation is licensed under the MIT License. -Okay, fine, I guess that means compliments aren't __required__. diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/Rakefile b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/Rakefile deleted file mode 100644 index bce0d84e14..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/Rakefile +++ /dev/null @@ -1,339 +0,0 @@ -# ----- Utility Functions ----- - -def scope(path) - File.join(File.dirname(__FILE__), path) -end - -# ----- Default: Testing ------ - -task :default => :test - -require 'rake/testtask' - -Rake::TestTask.new do |t| - t.libs << 'test' - test_files = FileList[scope('test/**/*_test.rb')] - test_files.exclude(scope('test/rails/*')) - test_files.exclude(scope('test/plugins/*')) - t.test_files = test_files - t.verbose = true -end - -# ----- Packaging ----- - -# Don't use Rake::GemPackageTast because we want prerequisites to run -# before we load the gemspec. -desc "Build all the packages." -task :package => [:revision_file, :submodules, :permissions] do - version = get_version - File.open(scope('VERSION'), 'w') {|f| f.puts(version)} - load scope('sass.gemspec') - Gem::Builder.new(SASS_GEMSPEC).build - sh %{git checkout VERSION} - - pkg = "#{SASS_GEMSPEC.name}-#{SASS_GEMSPEC.version}" - mkdir_p "pkg" - verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"} - - sh %{rm -f pkg/#{pkg}.tar.gz} - verbose(false) {SASS_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}} - sh %{gzip pkg/#{pkg}.tar} -end - -task :permissions do - sh %{chmod -R a+rx bin} - sh %{chmod -R a+r .} - require 'shellwords' - Dir.glob('test/**/*_test.rb') do |file| - next if file =~ %r{^test/haml/spec/} - sh %{chmod a+rx #{file}} - end -end - -task :revision_file do - require 'lib/sass' - - release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION')) - if Sass.version[:rev] && !release - File.open(scope('REVISION'), 'w') { |f| f.puts Sass.version[:rev] } - elsif release - File.open(scope('REVISION'), 'w') { |f| f.puts "(release)" } - else - File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" } - end -end - -# We also need to get rid of this file after packaging. -at_exit { File.delete(scope('REVISION')) rescue nil } - -desc "Install Sass as a gem. Use SUDO=1 to install with sudo." -task :install => [:package] do - gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem' - sh %{#{'sudo ' if ENV["SUDO"]}#{gem} install --no-ri pkg/sass-#{get_version}} -end - -desc "Release a new Sass package to Rubyforge." -task :release => [:check_release, :package] do - name = File.read(scope("VERSION_NAME")).strip - version = File.read(scope("VERSION")).strip - sh %{rubyforge add_release sass sass "#{name} (v#{version})" pkg/sass-#{version}.gem} - sh %{rubyforge add_file sass sass "#{name} (v#{version})" pkg/sass-#{version}.tar.gz} - sh %{gem push pkg/sass-#{version}.gem} -end - -# Ensures that the VERSION file has been updated for a new release. -task :check_release do - version = File.read(scope("VERSION")).strip - raise "There have been changes since current version (#{version})" if changed_since?(version) - raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read(scope("VERSION_NAME")) == "Bleeding Edge" -end - -# Reads a password from the command line. -# -# @param name [String] The prompt to use to read the password -def read_password(prompt) - require 'readline' - system "stty -echo" - Readline.readline("#{prompt}: ").strip -ensure - system "stty echo" - puts -end - -# Returns whether or not the repository, or specific files, -# has/have changed since a given revision. -# -# @param rev [String] The revision to check against -# @param files [Array] The files to check. -# If this is empty, checks the entire repository -def changed_since?(rev, *files) - IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {} - return !$?.success? -end - -task :submodules do - if File.exist?(File.dirname(__FILE__) + "/.git") - sh %{git submodule sync} - sh %{git submodule update --init} - elsif !File.exist?(File.dirname(__FILE__) + "/vendor/fssm/lib") - warn < :yard - task :redoc => :yard -rescue LoadError - desc "Generate Documentation" - task :doc => :rdoc - task :yard => :rdoc -end - -task :pages do - ensure_git_cleanup do - puts "#{'=' * 50} Running rake pages" - sh %{git checkout sass-pages} - sh %{git reset --hard origin/sass-pages} - - Dir.chdir("/var/www/sass-pages") do - sh %{git fetch origin} - - sh %{git checkout stable} - sh %{git reset --hard origin/stable} - - sh %{git checkout sass-pages} - sh %{git reset --hard origin/sass-pages} - sh %{rake build --trace} - sh %{mkdir -p tmp} - sh %{touch tmp/restart.txt} - end - end -end - -# ----- Coverage ----- - -begin - require 'rcov/rcovtask' - - Rcov::RcovTask.new do |t| - t.test_files = FileList[scope('test/**/*_test.rb')] - t.rcov_opts << '-x' << '"^\/"' - if ENV['NON_NATIVE'] - t.rcov_opts << "--no-rcovrt" - end - t.verbose = true - end -rescue LoadError; end - -# ----- Profiling ----- - -begin - require 'ruby-prof' - - desc < e - IO.popen("sendmail nex342@gmail.com", "w") do |sm| - sm << "From: nex3@nex-3.com\n" << - "To: nex342@gmail.com\n" << - "Subject: Exception when running rake #{Rake.application.top_level_tasks.join(', ')}\n" << - e.message << "\n\n" << - e.backtrace.join("\n") - end -ensure - raise e if e -end - -def ensure_git_cleanup - email_on_error {yield} -ensure - sh %{git reset --hard HEAD} - sh %{git clean -xdf} - sh %{git checkout master} -end - -task :handle_update do - email_on_error do - unless ENV["REF"] =~ %r{^refs/heads/(master|stable|sass-pages)$} - puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}" - next - end - branch = $1 - - puts - puts - puts '=' * 150 - puts "Running rake handle_update REF=#{ENV["REF"].inspect}" - - sh %{git fetch origin} - sh %{git checkout stable} - sh %{git reset --hard origin/stable} - sh %{git checkout master} - sh %{git reset --hard origin/master} - - case branch - when "master" - sh %{rake release_edge --trace} - when "stable", "sass-pages" - sh %{rake pages --trace} - end - - puts 'Done running handle_update' - puts '=' * 150 - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/TODO b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/TODO deleted file mode 100644 index b3591b8b08..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/TODO +++ /dev/null @@ -1,39 +0,0 @@ -# -*- mode: org -*- -#+STARTUP: nofold - -* Documentation - Redo tutorial? - Syntax highlighting? - -* Code - Keep track of error offsets everywhere - Use this to show error location in messages - Just clean up SassScript syntax errors in general - Lexer errors in particular are icky - See in particular error changes made in c07b5c8 -** Sass - Benchmark the effects of storing the raw template in sassc - If it's expensive, overload RootNode dumping/loading to dup and set @template to nil - Then fall back on reading from actual file - Make Rack middleware the default for Rails and Merb versions that support it - CSS superset - Classes are mixins - Can refer to specific property values? Syntax? - Pull in Compass watcher stuff - Internationalization - Particularly word constituents in Regexps - Optimization - http://csstidy.sourceforge.net/ - http://developer.yahoo.com/yui/compressor/ - Also comma-folding identical rules where possible - Multiple levels - 0: No optimization - 1: Nothing that changes doc structure - No comma-folding - 2: Anything that keeps functionality identical to O2 (default) - 3: Assume order of rules doesn't matter - Comma-fold even if there are intervening rules that might interfere - CSS3 - Add (optional) support for http://www.w3.org/TR/css3-values/#calc - Cross-unit arithmetic should compile into this - Should we use "mod" in Sass for consistency? diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/VERSION b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/VERSION deleted file mode 100644 index fd2a01863f..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.1.0 diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/VERSION_NAME b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/VERSION_NAME deleted file mode 100644 index 696137c3c7..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/VERSION_NAME +++ /dev/null @@ -1 +0,0 @@ -Brainy Betty diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/sass b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/sass deleted file mode 100755 index 2b01e92eee..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/sass +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby -# The command line Sass parser. - -require File.dirname(__FILE__) + '/../lib/sass' -require 'sass/exec' - -opts = Sass::Exec::Sass.new(ARGV) -opts.parse! diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/sass-convert b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/sass-convert deleted file mode 100755 index 97ee024f33..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/sass-convert +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../lib/sass' -require 'sass/exec' - -opts = Sass::Exec::SassConvert.new(ARGV) -opts.parse! diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/scss b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/scss deleted file mode 100755 index 0791cfb50d..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/bin/scss +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby -# The command line Sass parser. - -require File.dirname(__FILE__) + '/../lib/sass' -require 'sass/exec' - -opts = Sass::Exec::Scss.new(ARGV) -opts.parse! diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/FAQ.md b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/FAQ.md deleted file mode 100644 index e919ccdc96..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/FAQ.md +++ /dev/null @@ -1,35 +0,0 @@ -# Frequently Asked Questions - -* Table of contents -{:toc} - -## Can I use a variable from my controller in my Sass file? -{#q-ruby-code} - -No. Sass files aren't views. -They're compiled once into static CSS files, -then left along until they're changed and need to be compiled again. -Not only don't you want to be running a full request cycle -every time someone requests a stylesheet, -but it's not a great idea to put much logic in there anyway -due to how browsers handle them. - -If you really need some sort of dynamic CSS, -you can define your own {Sass::Script::Functions Sass functions} using Ruby -that can access the database or other configuration. -*Be aware when doing this that Sass files are by default only compiled once -and then served statically.* - -If you really, really need to compile Sass on each request, -first make sure you have adequate caching set up. -Then you can use {Sass::Engine} to render the code, -using the {file:SASS_REFERENCE.md#custom-option `:custom` option} -to pass in data that {Sass::Script::Functions::EvaluationContext#options can be accessed} -from your Sass functions. - -# You still haven't answered my question! - -Sorry! Try looking at the [Sass](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html) reference, -If you can't find an answer there, -feel free to ask in `#sass` on irc.freenode.net -or send an email to the [mailing list](http://groups.google.com/group/sass-lang). diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/INDENTED_SYNTAX.md b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/INDENTED_SYNTAX.md deleted file mode 100644 index f6b286c707..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/INDENTED_SYNTAX.md +++ /dev/null @@ -1,210 +0,0 @@ -# Sass Indented Syntax - -* Table of contents -{:toc} - -Sass's indented syntax (also known simply as "Sass") -is designed to provide a more concise -and, for some, more aesthetically appealing alternative -to the CSS-based SCSS syntax. -It's not compatible with CSS; -instead of using `{` and `}` to delimit blocks of styles, -it uses indentation, -and instead of using semicolons to separate statements it uses newlines. -This usually leads to substantially less text -when saying the same thing. - -Each statement in Sass, such as property declarations and selectors, -must be placed on its own line. -In addition, everything that would be within `{` and `}` after a statement -must be on a new line and indented one level deeper than that statement. -For example, this CSS: - - #main { - color: blue; - font-size: 0.3em; - } - -would be this Sass: - - #main - color: blue - font-size: 0.3em - -Similarly, this SCSS: - - #main { - color: blue; - font-size: 0.3em; - - a { - font: { - weight: bold; - family: serif; - } - &:hover { - background-color: #eee; - } - } - } - -would be this Sass: - - #main - color: blue - font-size: 0.3em - - a - font: - weight: bold - family: serif - &:hover - background-color: #eee - -## Sass Syntax Differences - -In general, most CSS and SCSS syntax -works straightforwardly in Sass -by using newlines instead of semicolons -and indentation instead of braces. -However, there are some cases where there are differences or subtleties, -which are detailed below. - -## Property Synax - -The indented syntax supports two ways of declaring CSS properties. -The first is just like CSS, except without the semicolon. -The second, however, places the colon *before* the property name. -For example: - - #main - :color blue - :font-size 0.3em - -By default, both ways may be used. -However, the {file:SASS_REFERENCE.md#property_syntax-option `:property_syntax` option} -may be used to specify that only one property syntax is allowed. - -### Multiline Selectors - -Normally in the indented syntax, a single selector must take up a single line. -There is one exception, however: -selectors can contain newlines as long as they only appear after commas. -For example: - - .users #userTab, - .posts #postTab - width: 100px - height: 30px - -### Comments - -Like everything else in the indented syntax, -comments are line-based. -This means that they don't work the same way as in SCSS. -They must take up an entire line, -and they also encompass all text nested beneath them. - -Like SCSS, the indented syntax supports two kinds of comments. -Comments beginning with `/*` are preserved in the CSS output, -although unlike SCSS they don't require a closing `*/`. -Comments beginning with `//` are removed entirely. -For example: - - /* This comment will appear in the CSS output. - This is nested beneath the comment, - so it's part of it - body - color: black - - // This comment will not appear in the CSS output. - This is nested beneath the comment as well, - so it also won't appear - a - color: green - -is compiled to: - - /* This comment will appear in the CSS output. - * This is nested beneath the comment, - * so it's part of it */ - body { - color: black; } - - a { - color: green; } - -### `@import` - -The `@import` directive in Sass does not require quotes, although they may be used. -For example, this SCSS: - - @import "themes/dark"; - @import "font.sass"; - -would be this Sass: - - @import themes/dark - @import font.sass - -### Mixin Directives - -Sass supports shorthands for the `@mixin` and `@include` directives. -Instead of writing `@mixin`, you can use the character `=`; -instead of writing `@include`, you can use the character `+`. -For example: - - =large-text - font: - family: Arial - size: 20px - weight: bold - color: #ff0000 - - h1 - +large-text - -is the same as: - - @mixin large-text - font: - family: Arial - size: 20px - weight: bold - color: #ff0000 - - h1 - @include large-text - -## Deprecated Syntax - -Since the indented syntax has been around for a while, -previous versions have made some syntactic decisions -that have since been changed. -Some of the old syntax still works, though, -so it's documented here. - -**Note that this syntax is not recommended -for use in new Sass files**. -It will print a warning if it's used, -and it will be removed in a future version. - -### `=` for Properties and Variables - -`=` used to be used instead of `:` when setting variables -and when setting properties to SassScript values. -It has slightly different semantics than `:`; -see {file:SASS_CHANGELOG.md#3-0-0-sass-script-context this changelog entry} for details. - -### `||=` for Default Variables - -`||=` used to be used instead of `:` when setting the default value of a variable. -The `!default` flag was not used. -The variable value has the same semantics as `=`; -see {file:SASS_CHANGELOG.md#3-0-0-sass-script-context this changelog entry} for details. - -### `!` Prefix for Variables - -`!` used to be used as the variable prefix instead of `$`. -This had no difference in functionality; -it was a purely aesthetic change. diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SASS_CHANGELOG.md b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SASS_CHANGELOG.md deleted file mode 100644 index f4d1ac97c7..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SASS_CHANGELOG.md +++ /dev/null @@ -1,2214 +0,0 @@ -# Sass Changelog - -* Table of contents -{:toc} - -## 3.1.0 (Unreleased) - -* Add an {Sass::Script::Functions#invert `invert` function} that takes the inverse of colors. - -* A new sass function called `if` can be used to emit one of two values - based on the truth value of the first argument. - For example, `if(true, 1px, 2px)` returns `1px` and `if(false, 1px, 2px)` returns `2px`. - -* Compass users can now use the `--compass` flag - to make the Compass libraries available for import. - This will also load the Compass project configuration - if run from the project root. - -* Many performance optimizations have been made by [thedarkone](http://github.com/thedarkone). - -* Allow selectors to contain extra commas to make them easier to modify. - Extra commas will be removed when the selectors are converted to CSS. - -* `@import` may now be used within CSS or `@media` rules. - The imported file will be treated as though it were nested within the rule. - Files with mixins may not be imported in nested contexts. - -* If a comment starts with `!`, that comment will now be interpolated - (`#{...}` will be replaced with the resulting value of the expression - inside) and the comment will always be printed out in the generated CSS - file -- even with compressed output. This is useful for adding copyright - notices to your stylesheets. - -* A new executable named `scss` is now available. It is exactly like the - `sass` executable except it defaults to assuming input is in the SCSS syntax. - Both programs will use the source file's extension to determine the syntax where - possible. - -### Sass-based Functions - -While it has always been possible to add functions to Sass with Ruby, this release adds the ability to define new functions within Sass files directly. -For example: - - $grid-width: 40px; - $gutter-width: 10px; - - @function grid-width($n) { - @return $n * $grid-width + ($n - 1) * $gutter-width; - } - - #sidebar { width: grid-width(5); } - -Becomes: - - #sidebar { - width: 240px; } - -### Keyword Arguments - -Both mixins and Sass functions now support the ability to pass in keyword arguments. -For example, with mixins: - - @mixin border-radius($value, $moz: true, $webkit: true, $css3: true) { - @if $moz { -moz-border-radius: $value } - @if $webkit { -webkit-border-radius: $value } - @if $css3 { border-radius: $value } - } - - @include border-radius(10px, $webkit: false); - -And with functions: - - p { - color: hsl($hue: 180, $saturation: 78%, $lightness: 57%); - } - -Keyword arguments are of the form `$name: value` and come after normal arguments. -They can be used for either optional or required arguments. -For mixins, the names are the same as the argument names for the mixins. -For functions, the names are defined along with the functions. -The argument names for the built-in functions are listed -{Sass::Script::Functions in the function documentation}. - -Sass functions defined in Ruby can use the {Sass::Script::Functions.declare} method -to declare the names of the arguments they take. - -#### New Keyword Functions - -The new keyword argument functionality enables new Sass color functions -that use keywords to encompass a large amount of functionality in one function. - -* The {Sass::Script::Functions#adjust_color adjust-color} function works like the old - `lighten`, `saturate`, and `adjust-hue` methods. - It increases and/or decreases the values of a color's properties by fixed amounts. - For example, `adjust-color($color, $lightness: 10%)` is the same as `lighten($color, 10%)`: - it returns `$color` with its lightness increased by 10%. - -* The {Sass::Script::Functions#scale_color scale_color} function - is similar to {Sass::Script::Functions#adjust adjust}, - but instead of increasing and/or decreasing a color's properties by fixed amounts, - it scales them fluidly by percentages. - The closer the percentage is to 100% (or -100%), - the closer the new property value will be to its maximum (or minimum). - For example, `scale-color(hsl(120, 70, 80), $lightness: 50%)` - will change the lightness from 80% to 90%, - because 90% is halfway between 80% and 100%. - Similarly, `scale-color(hsl(120, 70, 50), $lightness: 50%)` - will change the lightness from 50% to 75%. - -* The {Sass::Script::Functions#change_color change-color} function simply changes a color's properties - regardless of their old values. - For example `change-color($color, $lightness: 10%)` returns `$color` with 10% lightness, - and `change-color($color, $alpha: 0.7)` returns color with opacity 0.7. - -Each keyword function accepts `$hue`, `$saturation`, `$value`, -`$red`, `$green`, `$blue`, and `$alpha` keywords, -with the exception of `scale-color()` which doesn't accept `$hue`. -These keywords modify the respective properties of the given color. - -Each keyword function can modify multiple properties at once. -For example, `adjust-color($color, $lightness: 15%, $saturation: -10%)` -both lightens and desaturates `$color`. -HSL properties cannot be modified at the same time as RGB properties, though. - -### Lists - -Lists are now a first-class data type in Sass, -alongside strings, numbers, colors, and booleans. -They can be assigned to variables, passed to mixins, -and used in CSS declarations. -Just like the other data types (except booleans), -Sass lists look just like their CSS counterparts. -They can be separated either by spaces (e.g. `1px 2px 0 10px`) -or by commas (e.g. `Helvetica, Arial, sans-serif`). -In addition, individual values count as single-item lists. - -Lists won't behave any differently in Sass 3.1 than they did in 3.0. -However, you can now do more with them using the new {file:Sass/Script/Functions.html#list-functions list functions}: - -* The {Sass::Script::Functions#nth `nth($list, $n)` function} returns the nth item in a list. - For example, `nth(1px 2px 10px, 2)` returns the second item, `2px`. - Note that lists in Sass start at 1, not at 0 like they do in some other languages. - -* The {Sass::Script::Functions#join `join($list1, $list2)` function} - joins together two lists into one. - For example, `join(1px 2px, 10px 5px)` returns `1px 2px 10px 5px`. - -* The {Sass::Script::Functions#append `append($list, $val)` function} - appends values to the end of a list. - For example, `append(1px 2px, 10px)` returns `1px 2px 10px`. - -* The {Sass::Script::Functions#join `length($list)` function} - returns the length of a list. - For example, `length(1px 2px 10px 5px)` returns `4`. - -For more details about lists see {file:SASS_REFERENCE.md#lists the reference}. - -#### `@each` - -There's also a new directive that makes use of lists. -The {file:SASS_REFERENCE.md#each-directive `@each` directive} assigns a variable to each item in a list in turn, -like `@for` does for numbers. -This is useful for writing a bunch of similar styles -without having to go to the trouble of creating a mixin. -For example: - - @each $animal in puma, sea-slug, egret, salamander { - .#{$animal}-icon { - background-image: url('/images/#{$animal}.png'); - } - } - -is compiled to: - - .puma-icon { - background-image: url('/images/puma.png'); } - .sea-slug-icon { - background-image: url('/images/sea-slug.png'); } - .egret-icon { - background-image: url('/images/egret.png'); } - .salamander-icon { - background-image: url('/images/salamander.png'); } - -### `@media` Bubbling - -Modern stylesheets often use `@media` rules to target styles -at certain sorts of devices, screen resolutions, or even orientations. -They're also useful for print and aural styling. -Unfortunately, it's annoying and repetitive to break the flow of a stylesheet -and add a `@media` rule containing selectors you've already written -just to tweak the style a little. - -Thus, Sass 3.1 now allows you to nest `@media` rules within selectors. -It will automatically bubble them up to the top level, -putting all the selectors on the way inside the rule. -For example: - - .sidebar { - width: 300px; - @media screen and (orientation: landscape) { - width: 500px; - } - } - -is compiled to: - - .sidebar { - width: 300px; - } - @media screen and (orientation: landscape) { - .sidebar { - width: 500px; - } - } - -You can also nest `@media` directives within one another. -The queries will then be combined using the `and` operator. -For example: - - @media screen { - .sidebar { - @media (orientation: landscape) { - width: 500px; - } - } - } - -is compiled to: - - @media screen and (orientation: landscape) { - .sidebar { - width: 500px; - } - } - -### Nested `@import` - -The `@import` statement can now be nested within other structures -such as CSS rules and `@media` rules. For example: - - @media print { - @import "print"; - } - -This imports `print.scss` and places all rules so imported within the `@media print` block. -This makes it easier to create stylesheets for specific media or sections of the document -and distributing those stylesheets across multiple files. - -### Backwards Incompatibilities -- Must Read! - -* When `@import` is given a path without `.sass`, `.scss`, or `.css` extension, - and no file exists at that path, it will now throw an error. - The old behavior of becoming a plain-CSS `@import` was deprecated - and has now been removed. - -* Get rid of the `--rails` flag for the `sass` executable. - This flag hasn't been necessary since Rails 2.0. - Existing Rails 2.0 installations will continue to work. - -* Removed deprecated support for ! prefixed variables. Use $ to prefix variables now. - -* Removed the deprecated css2sass executable. Use sass-convert now. - -* Removed support for the equals operator in variable assignment. Use : now. - -* Removed the sass2 mode from sass-convert. Users who have to migrate from sass2 - should install Sass 3.0 and quiet all deprecation warnings before installing Sass 3.1. - -### Sass Internals - -* It is now possible to define a custom importer that can be used to find imports using different import semantics than the default filesystem importer that Sass provides. For instance, you can use this to generate imports on the fly, look them up from a database, or implement different file naming conventions. See the {Sass::Importers::Base Importer Base class} for more information. - -* It is now possible to define a custom cache store to allow for efficient caching of Sass files using alternative cache stores like memcached in environments where a writable filesystem is not available or where the cache need to be shared across many servers for dynamically generated stylesheet environments. See the {Sass::CacheStores::Base CacheStore Base class} for more information. - -## 3.0.26 (Unreleased) - -* Fix a performance bug in large SCSS stylesheets with many nested selectors. - This should dramatically decrease compilation time of such stylesheets. - -* Upgrade the bundled FSSM to version 0.2.3. - This means `sass --watch` will work out of the box with Rubinius. - -## 3.0.25 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.25). - -* When displaying a Sass error in an imported stylesheet, - use the imported stylesheet's contents rather than the top-level stylesheet. - -* Fix a bug that caused some lines with non-ASCII characters to be ignored in Ruby 1.8. - -* Fix a bug where boolean operators (`and`, `or`, and `not`) wouldn't work at the end of a line - in a multiline SassScript expression. - -* When using `sass --update`, only update individual files when they've changed. - -## 3.0.24 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.24). - -* Raise an error when `@else` appears without an `@if` in SCSS. - -* Fix some cases where `@if` rules were causing the line numbers in error reports - to become incorrect. - -## 3.0.23 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.23). - -* Fix the error message for unloadable modules when running the executables under Ruby 1.9.2. - -### `@charset` Change - -The behavior of `@charset` has changed in version 3.0.23 -in order to work around a bug in Safari, -where `@charset` declarations placed anywhere other than the beginning of the document -cause some CSS rules to be ignored. -This change also makes `@charset`s in imported files behave in a more useful way. - -#### Ruby 1.9 - -When using Ruby 1.9, which keeps track of the character encoding of the Sass document internally, -`@charset` directive in the Sass stylesheet and any stylesheets it imports -are no longer directly output to the generated CSS. -They're still used for determining the encoding of the input and output stylesheets, -but they aren't rendered in the same way other directives are. - -Instead, Sass adds a single `@charset` directive at the beginning of the output stylesheet -if necessary, whether or not the input stylesheet had a `@charset` directive. -It will add this directive if and only if the output stylesheet contains non-ASCII characters. -By default, the declared charset will be UTF-8, -but if the Sass stylesheet declares a different charset then that will be used instead if possible. - -One important consequence of this scheme is that it's possible for a Sass file -to import partials with different encodings (e.g. one encoded as UTF-8 and one as IBM866). -The output will then be UTF-8, unless the importing stylesheet -declares a different charset. - -#### Ruby 1.8 - -Ruby 1.8 doesn't have good support for encodings, so it uses a simpler but less accurate -scheme for figuring out what `@charset` declaration to use for the output stylesheet. -It just takes the first `@charset` declaration to appear in the stylesheet -or any of its imports and moves it to the beginning of the document. -This means that under Ruby 1.8 it's *not* safe to import files with different encodings. - -## 3.0.22 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.22). - -* Remove `vendor/sass`, which snuck into the gem by mistake - and was causing trouble for Heroku users (thanks to [Jacques Crocker](http://railsjedi.com/)). - -* `sass-convert` now understands better when it's acceptable - to remove parentheses from expressions. - -## 3.0.21 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.21). - -* Fix the permissions errors for good. - -* Fix more `#options` attribute errors. - -## 3.0.20 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.20). - -* Fix some permissions errors. - -* Fix `#options` attribute errors when CSS functions were used with commas. - -## 3.0.19 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.19). - -* Make the alpha value for `rgba` colors respect {Sass::Script::Number::PRECISION}. - -* Remove all newlines in selectors in `:compressed` mode. - -* Make color names case-insensitive. - -* Properly detect SCSS files when using `sass -c`. - -* Remove spaces after commas in `:compressed` mode. - -* Allow the `--unix-newlines` flag to work on Unix, where it's a no-op. - -## 3.0.18 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.18). - -* Don't require `rake` in the gemspec, for bundler compatibility under - JRuby. Thanks to [Gordon McCreight](http://www.gmccreight.com/blog). - -* Add a command-line option `--stop-on-error` that causes Sass to exit - when a file fails to compile using `--watch` or `--update`. - -* Fix a bug in `haml_tag` that would allow duplicate attributes to be added - and make `data-` attributes not work. - -* Get rid of the annoying RDoc errors on install. - -* Disambiguate references to the `Rails` module when `haml-rails` is installed. - -* Allow `@import` in SCSS to import multiple files in the same `@import` rule. - -## 3.0.17 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.17). - -* Disallow `#{}` interpolation in `@media` queries or unrecognized directives. - This was never allowed, but now it explicitly throws an error - rather than just producing invalid CSS. - -* Make `sass --watch` not throw an error when passed a single file or directory. - -* Understand that mingw counts as Windows. - -* Make `sass --update` return a non-0 exit code if one or more files being updated - contained an error. - -## 3.0.16 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.16). - -* Fix a bug where certain sorts of comments would get improperly - rendered in the `:compact` style. - -* Always allow a trailing `*/` in loud comments in the indented syntax. - -* Fix a performance issue with SCSS parsing in rare cases. - Thanks to [Chris Eppstein](http://chriseppstein.github.com). - -* Use better heuristics for figuring out when someone might be using - the wrong syntax with `sass --watch`. - -## 3.0.15 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.15). - -* Fix a bug where `sass --watch` and `sass --update` were completely broken. - -* Allow `@import`ed values to contain commas. - -## 3.0.14 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.14). - -* Properly parse paths with drive letters on Windows (e.g. `C:\Foo\Bar.sass`) - in the Sass executable. - -* Compile Sass files in a deterministic order. - -* Fix a bug where comments after `@if` statements in SCSS - weren't getting passed through to the output document. - -## 3.0.13 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.13). - -## CSS `@import` Directives - -Sass is now more intelligent about when to compile `@import` directives to plain CSS. -Any of the following conditions will cause a literal CSS `@import`: - -* Importing a path with a `.css` extension (e.g. `@import "foo.css"`). -* Importing a path with a media type (e.g. `@import "foo" screen;`). -* Importing an HTTP path (e.g. `@import "http://foo.com/style.css"`). -* Importing any URL (e.g. `@import url(foo)`). - -The former two conditions always worked, but the latter two are new. - -## `-moz-calc` Support - -The new [`-moz-calc()` function](http://hacks.mozilla.org/2010/06/css3-calc/) in Firefox 4 -will now be properly parsed by Sass. -`calc()` was already supported, but because the parsing rules are different -than for normal CSS functions, this had to be expanded to include `-moz-calc`. - -In anticipation of wider browser support, in fact, -*any* function named `-*-calc` (such as `-webkit-calc` or `-ms-calc`) -will be parsed the same as the `calc` function. - -## `:-moz-any` Support - -The [`:-moz-any` pseudoclass selector](http://hacks.mozilla.org/2010/05/moz-any-selector-grouping/) -is now parsed by Sass. - -## `--require` Flag - -The Sass command-line executable can now require Ruby files -using the `--require` flag (or `-r` for short). - -## Rails Support - -Make sure the default Rails options take precedence over the default non-Rails options. -This makes `./script/server --daemon` work again. - -### Rails 3 Support - -Support for Rails 3 versions prior to beta 4 has been removed. -Upgrade to Rails 3.0.0.beta4 if you haven't already. - -## 3.0.12 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.12). - -## Rails 3 Support - -Apparently the last version broke in new and exciting ways under Rails 3, -due to the inconsistent load order caused by certain combinations of gems. -3.0.12 hacks around that inconsistency, and *should* be fully Rails 3-compatible. - -### Deprecated: Rails 3 Beta 3 - -Haml's support for Rails 3.0.0.beta.3 has been deprecated. -Haml 3.0.13 will only support 3.0.0.beta.4. - -## 3.0.11 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.11). - -There were no changes made to Haml between versions 3.0.10 and 3.0.11. - -## Rails 3 Support - -Make sure Sass *actually* regenerates stylesheets under Rails 3. -The fix in 3.0.10 didn't work because the Rack stack we were modifying -wasn't reloaded at the proper time. - -## Bug Fixes - -* Give a decent error message when `--recursive` is used - in `sass-convert` without a directory. - -## 3.0.10 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.10). - -### Appengine-JRuby Support - -The way we determine the location of the Haml installation -no longer breaks the version of JRuby -used by [`appengine-jruby`](http://code.google.com/p/appengine-jruby/). - -### Rails 3 Support - -Sass will regenerate stylesheets under Rails 3 -even when no controllers are being accessed. - -### Other Improvements - -* When using `sass-convert --from sass2 --to sass --recursive`, - suggest the use of `--in-place` as well. - -## 3.0.9 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.9). - -There were no changes made to Sass between versions 3.0.8 and 3.0.9. -A bug in Gemcutter caused the gem to be uploaded improperly. - -## 3.0.8 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.8). - -* Fix a bug with Rails versions prior to Rails 3. - -## 3.0.7 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.7). - -### Encoding Support - -Sass 3.0.7 adds support for `@charset` for declaring the encoding of a stylesheet. -For details see {file:SASS_REFERENCE.md#encodings the reference}. - -The `sass` and `sass-convert` executables also now take an `-E` option -for specifying the encoding of Sass/SCSS/CSS files. - -### Bug Fixes - -* When compiling a file named `.sass` but with SCSS syntax specified, - use the latter (and vice versa). - -* Fix a bug where interpolation would cause some selectors to render improperly. - -* If a line in a Sass comment starts with `*foo`, - render it as `*foo` rather than `* *foo`. - -## 3.0.6 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.6). - -There were no changes made to Sass between versions 3.0.5 and 3.0.6. - -## 3.0.5 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.5). - -### `#{}` Interpolation in Properties - -Previously, using `#{}` in some places in properties -would cause a syntax error. -Now it can be used just about anywhere. - -Note that when `#{}` is used near operators like `/`, -those operators are treated as plain CSS -rather than math operators. -For example: - - p { - $font-size: 12px; - $line-height: 30px; - font: #{$font-size}/#{$line-height}; - } - -is compiled to: - - p { - font: 12px/30px; - } - -This is useful, since normally {file:SASS_REFERENCE.md#division-and-slash -a slash with variables is treated as division}. - -### Recursive Mixins - -Mixins that include themselves will now print -much more informative error messages. -For example: - - @mixin foo {@include bar} - @mixin bar {@include foo} - @include foo - -will print: - - An @include loop has been found: - foo includes bar - bar includes foo - -Although it was previously possible to use recursive mixins -without causing infinite looping, this is now disallowed, -since there's no good reason to do it. - -### Rails 3 Support - -Fix Sass configuration under Rails 3. -Thanks [Dan Cheail](http://github.com/codeape). - -### `sass --no-cache` - -Make the `--no-cache` flag properly forbid Sass from writing `.sass-cache` files. - -## 3.0.4 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.4). - -* Raise an informative error when function arguments have a mispaced comma, - as in `foo(bar, )`. - -* Fix a performance problem when using long function names - such as `-moz-linear-gradient`. - -## 3.0.3 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.3). - -### Rails 3 Support - -Make sure Sass is loaded properly when using Rails 3 -along with non-Rails-3-compatible plugins like some versions of `will_paginate`. - -Also, In order to make some Rails loading errors like the above easier to debug, -Sass will now raise an error if `Rails.root` is `nil` when Sass is loading. -Previously, this would just cause the paths to be mis-set. - -### Merb Support - -Merb, including 1.1.0 as well as earlier versions, -should *really* work with this release. - -### Bug Fixes - -* Raise an informative error when mixin arguments have a mispaced comma, - as in `@include foo(bar, )`. - -* Make sure SassScript subtraction happens even when nothing else dynamic is going on. - -* Raise an error when colors are used with the wrong number of digits. - -## 3.0.2 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.2). - -### Merb 1.1.0 Support - -Fixed a bug inserting the Sass plugin into the Merb 1.1.0 Rack application. - -### Bug Fixes - -* Allow identifiers to begin with multiple underscores. - -* Don't raise an error when using `haml --rails` with older Rails versions. - -## 3.0.1 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.1). - -### Installation in Rails - -`haml --rails` is no longer necessary for installing Sass in Rails. -Now all you need to do is add `gem "haml"` to the Gemfile for Rails 3, -or add `config.gem "haml"` to `config/environment.rb` for previous versions. - -`haml --rails` will still work, -but it has been deprecated and will print an error message. -It will not work in the next version of Sass. - -### Rails 3 Beta Integration - -* Make sure manually importing the Sass Rack plugin still works with Rails, - even though it's not necessary now. - -* Allow Sass to be configured in Rails even when it's being lazy-loaded. - -### `:template_location` Methods - -The {file:SASS_REFERENCE.md#template_location-option `:template_location` option} -can be either a String, a Hash, or an Array. -This makes it difficult to modify or use with confidence. -Thus, three new methods have been added for handling it: - -* {Sass::Plugin::Configuration#template_location_array Sass::Plugin#template_location_array} -- - Returns the template locations and CSS locations formatted as an array. - -* {Sass::Plugin::Configuration#add_template_location Sass::Plugin#add_template_location} -- - Converts the template location option to an array and adds a new location. - -* {Sass::Plugin::Configuration#remove_template_location Sass::Plugin#remove_template_location} -- - Converts the template location option to an array and removes an existing location. - -## 3.0.0 -{#3-0-0} - -[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0). - -### Deprecations -- Must Read! -{#3-0-0-deprecations} - -* Using `=` for SassScript properties and variables is deprecated, - and will be removed in Sass 3.2. - Use `:` instead. - See also [this changelog entry](#3-0-0-sass-script-context) - -* Because of the above, property values using `:` - will be parsed more thoroughly than they were before. - Although all valid CSS3 properties - as well as most hacks and proprietary syntax should be supported, - it's possible that some properties will break. - If this happens, please report it to [the Sass mailing list](http://groups.google.com/group/haml). - -* In addition, setting the default value of variables - with `||=` is now deprecated - and will be removed in Sass 3.2. - Instead, add `!default` to the end of the value. - See also [this changelog entry](#3-0-0-default-flag) - -* The `!` prefix for variables is deprecated, - and will be removed in Sass 3.2. - Use `$` as a prefix instead. - See also [this changelog entry](#3-0-0-dollar-prefix). - -* The `css2sass` command-line tool has been deprecated, - and will be removed in Sass 3.2. - Use the new `sass-convert` tool instead. - See also [this changelog entry](#3-0-0-sass-convert). - -* Selector parent references using `&` can now only be used - where element names are valid. - This is because Sass 3 fully parses selectors - to support the new [`@extend` directive](#3-0-0-extend), - and it's possible that the `&` could be replaced by an element name. - -### SCSS (Sassy CSS) - -Sass 3 introduces a new syntax known as SCSS -which is fully compatible with the syntax of CSS3, -while still supporting the full power of Sass. -This means that every valid CSS3 stylesheet -is a valid SCSS file with the same meaning. -In addition, SCSS understands most CSS hacks -and vendor-specific syntax, such as [IE's old `filter` syntax](http://msdn.microsoft.com/en-us/library/ms533754%28VS.85%29.aspx). - -SCSS files use the `.scss` extension. -They can import `.sass` files, and vice-versa. -Their syntax is fully described in the {file:SASS_REFERENCE.md Sass reference}; -if you're already familiar with Sass, though, -you may prefer the {file:SCSS_FOR_SASS_USERS.md intro to SCSS for Sass users}. - -Since SCSS is a much more approachable syntax for those new to Sass, -it will be used as the default syntax for the reference, -as well as for most other Sass documentation. -The indented syntax will continue to be fully supported, however. - -Sass files can be converted to SCSS using the new `sass-convert` command-line tool. -For example: - - # Convert a Sass file to SCSS - $ sass-convert style.sass style.scss - -**Note that if you're converting a Sass file written for Sass 2**, -you should use the `--from sass2` flag. -For example: - - # Convert a Sass file to SCSS - $ sass-convert --from sass2 style.sass style.scss - - # Convert all Sass files to SCSS - $ sass-convert --recursive --in-place --from sass2 --to scss stylesheets/ - -### Syntax Changes {#3-0-0-syntax-changes} - -#### SassScript Context -{#3-0-0-sass-script-context} - -The `=` character is no longer required for properties that use SassScript -(that is, variables and operations). -All properties now use SassScript automatically; -this means that `:` should be used instead. -Variables should also be set with `:`. -For example, what used to be - - // Indented syntax - .page - color = 5px + 9px - -should now be - - // Indented syntax - .page - color: 5px + 9px - -This means that SassScript is now an extension of the CSS3 property syntax. -All valid CSS3 properties are valid SassScript, -and will compile without modification -(some invalid properties work as well, such as Microsoft's proprietary `filter` syntax). -This entails a few changes to SassScript to make it fully CSS3-compatible, -which are detailed below. - -This also means that Sass will now be fully parsing all property values, -rather than passing them through unchanged to the CSS. -Although care has been taken to support all valid CSS3, -as well as hacks and proprietary syntax, -it's possible that a property that worked in Sass 2 won't work in Sass 3. -If this happens, please report it to [the Sass mailing list](http://groups.google.com/group/haml). - -Note that if `=` is used, -SassScript will be interpreted as backwards-compatibly as posssible. -In particular, the changes listed below don't apply in an `=` context. - -The `sass-convert` command-line tool can be used -to upgrade Sass files to the new syntax using the `--in-place` flag. -For example: - - # Upgrade style.sass: - $ sass-convert --in-place style.sass - - # Upgrade all Sass files: - $ sass-convert --recursive --in-place --from sass2 --to sass stylesheets/ - -##### Quoted Strings - -Quoted strings (e.g. `"foo"`) in SassScript now render with quotes. -In addition, unquoted strings are no longer deprecated, -and render without quotes. -This means that almost all strings that had quotes in Sass 2 -should not have quotes in Sass 3. - -Although quoted strings render with quotes when used with `:`, -they do not render with quotes when used with `#{}`. -This allows quoted strings to be used for e.g. selectors -that are passed to mixins. - -Strings can be forced to be quoted and unquoted using the new -\{Sass::Script::Functions#unquote unquote} and \{Sass::Script::Functions#quote quote} -functions. - -##### Division and `/` - -Two numbers separated by a `/` character -are allowed as property syntax in CSS, -e.g. for the `font` property. -SassScript also uses `/` for division, however, -which means it must decide what to do -when it encounters numbers separated by `/`. - -For CSS compatibility, SassScript does not perform division by default. -However, division will be done in almost all cases where division is intended. -In particular, SassScript will perform division -in the following three situations: - -1. If the value, or any part of it, is stored in a variable. -2. If the value is surrounded by parentheses. -3. If the value is used as part of another arithmetic expression. - -For example: - - p - font: 10px/8px - $width: 1000px - width: $width/2 - height: (500px/2) - margin-left: 5px + 8px/2px - -is compiled to: - - p { - font: 10px/8px; - width: 500px; - height: 250px; - margin-left: 9px; } - -##### Variable Defaults - -Since `=` is no longer used for variable assignment, -assigning defaults to variables with `||=` no longer makes sense. -Instead, the `!default` flag -should be added to the end of the variable value. -This syntax is meant to be similar to CSS's `!important` flag. -For example: - - $var: 12px !default; - -#### Variable Prefix Character -{#3-0-0-dollar-prefix} - -The Sass variable character has been changed from `!` -to the more aesthetically-appealing `$`. -For example, what used to be - - !width = 13px - .icon - width = !width - -should now be - - $width: 13px - .icon - width: $width - -The `sass-convert` command-line tool can be used -to upgrade Sass files to the new syntax using the `--in-place` flag. -For example: - - # Upgrade style.sass: - $ sass-convert --in-place style.sass - - # Upgrade all Sass files: - $ sass-convert --recursive --in-place --from sass2 --to sass stylesheets/ - -`!` may still be used, but it's deprecated and will print a warning. -It will be removed in the next version of Sass, 3.2. - -#### Variable and Mixin Names - -SassScript variable and mixin names may now contain hyphens. -In fact, they may be any valid CSS3 identifier. -For example: - - $prettiest-color: #542FA9 - =pretty-text - color: $prettiest-color - -In order to allow frameworks like [Compass](http://compass-style.org) -to use hyphens in variable names -while maintaining backwards-compatibility, -variables and mixins using hyphens may be referred to -with underscores, and vice versa. -For example: - - $prettiest-color: #542FA9 - .pretty - // Using an underscore instead of a hyphen works - color: $prettiest_color - -#### Single-Quoted Strings - -SassScript now supports single-quoted strings. -They behave identically to double-quoted strings, -except that single quotes need to be backslash-escaped -and double quotes do not. - -#### Mixin Definition and Inclusion - -Sass now supports the `@mixin` directive as a way of defining mixins (like `=`), -as well as the `@include` directive as a way of including them (like `+`). -The old syntax is *not* deprecated, -and the two are fully compatible. -For example: - - @mixin pretty-text - color: $prettiest-color - - a - @include pretty-text - -is the same as: - - =pretty-text - color: $prettiest-color - - a - +pretty-text - -#### Sass Properties - -New-style properties (with the colon after the name) in indented syntax -now allow whitespace before the colon. For example: - - foo - color : blue - -#### Sass `@import` - -The Sass `@import` statement now allows non-CSS files to be specified with quotes, -for similarity with the SCSS syntax. For example, `@import "foo.sass"` -will now import the `foo.sass` file, rather than compiling to `@import "foo.sass";`. - -### `@extend` -{#3-0-0-extend} - -There are often cases when designing a page -when one class should have all the styles of another class, -as well as its own specific styles. -The most common way of handling this is to use both the more general class -and the more specific class in the HTML. -For example, suppose we have a design for a normal error -and also for a serious error. We might write our markup like so: - -
    - Oh no! You've been hacked! -
    - -And our styles like so: - - .error { - border: 1px #f00; - background-color: #fdd; - } - .seriousError { - border-width: 3px; - } - -Unfortunately, this means that we have to always remember -to use `.error` with `.seriousError`. -This is a maintenance burden, leads to tricky bugs, -and can bring non-semantic style concerns into the markup. - -The `@extend` directive avoids these problems -by telling Sass that one selector should inherit the styles of another selector. -For example: - - .error { - border: 1px #f00; - background-color: #fdd; - } - .seriousError { - @extend .error; - border-width: 3px; - } - -This means that all styles defined for `.error` -are also applied to `.seriousError`, -in addition to the styles specific to `.seriousError`. -In effect, everything with class `.seriousError` also has class `.error`. - -Other rules that use `.error` will work for `.seriousError` as well. -For example, if we have special styles for errors caused by hackers: - - .error.intrusion { - background-image: url("/image/hacked.png"); - } - -Then `
    ` -will have the `hacked.png` background image as well. - -#### How it Works - -`@extend` works by inserting the extending selector (e.g. `.seriousError`) -anywhere in the stylesheet that the extended selector (.e.g `.error`) appears. -Thus the example above: - - .error { - border: 1px #f00; - background-color: #fdd; - } - .error.intrusion { - background-image: url("/image/hacked.png"); - } - .seriousError { - @extend .error; - border-width: 3px; - } - -is compiled to: - - .error, .seriousError { - border: 1px #f00; - background-color: #fdd; } - - .error.intrusion, .seriousError.intrusion { - background-image: url("/image/hacked.png"); } - - .seriousError { - border-width: 3px; } - -When merging selectors, `@extend` is smart enough -to avoid unnecessary duplication, -so something like `.seriousError.seriousError` gets translated to `.seriousError`. -In addition, it won't produce selectors that can't match anything, like `#main#footer`. - -See also {file:SASS_REFERENCE.md#extend the `@extend` reference documentation}. - -### Colors - -SassScript color values are much more powerful than they were before. -Support was added for alpha channels, -and most of Chris Eppstein's [compass-colors](http://chriseppstein.github.com/compass-colors) plugin -was merged in, providing color-theoretic functions for modifying colors. - -One of the most interesting of these functions is {Sass::Script::Functions#mix mix}, -which mixes two colors together. -This provides a much better way of combining colors and creating themes -than standard color arithmetic. - -#### Alpha Channels - -Sass now supports colors with alpha channels, -constructed via the {Sass::Script::Functions#rgba rgba} -and {Sass::Script::Functions#hsla hsla} functions. -Alpha channels are unaffected by color arithmetic. -However, the {Sass::Script::Functions#opacify opacify} -and {Sass::Script::Functions#transparentize transparentize} functions -allow colors to be made more and less opaque, respectively. - -Sass now also supports functions that return the values of the -{Sass::Script::Functions#red red}, -{Sass::Script::Functions#blue blue}, -{Sass::Script::Functions#green green}, -and {Sass::Script::Functions#alpha alpha} -components of colors. - -#### HSL Colors - -Sass has many new functions for using the HSL values of colors. -For an overview of HSL colors, check out [the CSS3 Spec](http://www.w3.org/TR/css3-color/#hsl-color). -All these functions work just as well on RGB colors -as on colors constructed with the {Sass::Script::Functions#hsl hsl} function. - -* The {Sass::Script::Functions#lighten lighten} - and {Sass::Script::Functions#darken darken} - functions adjust the lightness of a color. - -* The {Sass::Script::Functions#saturate saturate} - and {Sass::Script::Functions#desaturate desaturate} - functions adjust the saturation of a color. - -* The {Sass::Script::Functions#adjust_hue adjust-hue} - function adjusts the hue of a color. - -* The {Sass::Script::Functions#hue hue}, - {Sass::Script::Functions#saturation saturation}, - and {Sass::Script::Functions#lightness lightness} - functions return the corresponding HSL values of the color. - -* The {Sass::Script::Functions#grayscale grayscale} - function converts a color to grayscale. - -* The {Sass::Script::Functions#complement complement} - function returns the complement of a color. - -### Other New Functions - -Several other new functions were added to make it easier to have -more flexible arguments to mixins and to enable deprecation -of obsolete APIs. - -* {Sass::Script::Functions#type_of `type-of`} -- Returns the type of a value. -* {Sass::Script::Functions#unit `unit`} -- - Returns the units associated with a number. -* {Sass::Script::Functions#unitless `unitless`} -- - Returns whether a number has units or not. -* {Sass::Script::Functions#comparable `comparable`} -- - Returns whether two numbers can be added or compared. - -### Watching for Updates -{#3-0-0-watch} - -The `sass` command-line utility has a new flag: `--watch`. -`sass --watch` monitors files or directories for updated Sass files -and compiles those files to CSS automatically. -This will allow people not using Ruby or [Compass](http://compass-style.org) -to use Sass without having to manually recompile all the time. - -Here's the syntax for watching a directory full of Sass files: - - sass --watch app/stylesheets:public/stylesheets - -This will watch every Sass file in `app/stylesheets`. -Whenever one of them changes, -the corresponding CSS file in `public/stylesheets` will be regenerated. -Any files that import that file will be regenerated, too. - -The syntax for watching individual files is the same: - - sass --watch style.sass:out.css - -You can also omit the output filename if you just want it to compile to name.css. -For example: - - sass --watch style.sass - -This will update `style.css` whenever `style.sass` changes. - -You can list more than one file and/or directory, -and all of them will be watched: - - sass --watch foo/style:public/foo bar/style:public/bar - sass --watch screen.sass print.sass awful-hacks.sass:ie.css - sass --watch app/stylesheets:public/stylesheets public/stylesheets/test.sass - -File and directory watching is accessible from Ruby, -using the {Sass::Plugin::Compiler#watch Sass::Plugin#watch} function. - -#### Bulk Updating - -Another new flag for the `sass` command-line utility is `--update`. -It checks a group of Sass files to see if their CSS needs to be updated, -and updates if so. - -The syntax for `--update` is just like watch: - - sass --update app/stylesheets:public/stylesheets - sass --update style.sass:out.css - sass --watch screen.sass print.sass awful-hacks.sass:ie.css - -In fact, `--update` work exactly the same as `--watch`, -except that it doesn't continue watching the files -after the first check. - -### `sass-convert` (née `css2sass`) {#3-0-0-sass-convert} - -The `sass-convert` tool, which used to be known as `css2sass`, -has been greatly improved in various ways. -It now uses a full-fledged CSS3 parser, -so it should be able to handle any valid CSS3, -as well as most hacks and proprietary syntax. - -`sass-convert` can now convert between Sass and SCSS. -This is normally inferred from the filename, -but it can also be specified using the `--from` and `--to` flags. -For example: - - $ generate-sass | sass-convert --from sass --to scss | consume-scss - -It's also now possible to convert a file in-place -- -that is, overwrite the old file with the new file. -This is useful for converting files in the [Sass 2 syntax](#3-0-0-deprecations) -to the new Sass 3 syntax, -e.g. by doing `sass-convert --in-place --from sass2 style.sass`. - -#### `--recursive` - -The `--recursive` option allows `sass-convert` to convert an entire directory of files. -`--recursive` requires both the `--from` and `--to` flags to be specified. -For example: - - # Convert all .sass files in stylesheets/ to SCSS. - # "sass2" means that these files are assumed to use the Sass 2 syntax. - $ sass-convert --recursive --from sass2 --to scss stylesheets/ - -#### `--dasherize` - -The `--dasherize` options converts all underscores to hyphens, -which are now allowed as part of identifiers in Sass. -Note that since underscores may still be used in place of hyphens -when referring to mixins and variables, -this won't cause any backwards-incompatibilities. - -#### Convert Less to SCSS - -`sass-convert` can also convert [Less](http://lesscss.org) files -to SCSS (or the indented syntax, although I anticipate less interest in that). -For example: - - # Convert all .less files in the current directory into .scss files - sass-convert --from less --to scss --recursive . - -This is done using the Less parser, so it requires that the `less` RubyGem be installed. - -##### Incompatibilities - -Because of the reasonably substantial differences between Sass and Less, -there are some things that can't be directly translated, -and one feature that can't be translated at all. -In the tests I've run on open-source Less stylesheets, -none of these have presented issues, but it's good to be aware of them. - -First, Less doesn't distinguish fully between mixins and selector inheritance. -In Less, all classes and some other selectors may be used as mixins, -alongside more Sass-like mixins. -If a class is being used as a mixin, -it may also be used directly in the HTML, -so it's not safe to translate it into a Sass mixin. -What `sass-convert` does instead is leave the class in the stylesheet as a class, -and use {file:SASS_REFERENCE.md#extend `@extend`} -rather than {file:SASS_REFERENCE.md#including_a_mixin `@include`} -to take on the styles of that class. -Although `@extend` and mixins work quite differently, -using `@extend` here doesn't actually seem to make a difference in practice. - -Another issue with Less mixins is that Less allows nested selectors -(such as `.body .button` or `.colors > .teal`) to be used -as a means of "namespacing" mixins. -Sass's `@extend` doesn't work that way, -so it does away with the namespacing and just extends the base class -(so `.colors > .teal` becomes simply `@extend .teal`). -In practice, this feature doesn't seem to be widely-used, -but `sass-convert` will print a warning and leave a comment -when it encounters it just in case. - -Finally, Less has the ability to directly access variables and property values -defined in other selectors, which Sass does not support. -Whenever such an accessor is used, -`sass-convert` will print a warning -and comment it out in the SCSS output. -Like namespaced mixins, though, -this does not seem to be a widely-used feature. - -### `@warn` Directive - -A new directive `@warn` has been added that allows Sass libraries to emit warnings. -This can be used to issue deprecation warnings, discourage sloppy use of mixins, etc. -`@warn` takes a single argument: a SassScript expression that will be -displayed on the console along with a stylesheet trace for locating the warning. -For example: - - @mixin blue-text { - @warn "The blue-text mixin is deprecated. Use new-blue-text instead."; - color: #00f; - } - -Warnings may be silenced with the new `--quiet` command line option, -or the corresponding {file:SASS_REFERENCE.md#quiet-option `:quiey` Sass option}. -This option will also affect warnings printed by Sass itself. -Warnings are off by default in the Rails, Rack, and Merb production environments. - -### Sass::Plugin API - -{Sass::Plugin} now has a large collection of callbacks that allow users -to run code when various actions are performed. -For example: - - Sass::Plugin.on_updating_stylesheet do |template, css| - puts "#{template} has been compiled to #{css}!" - end - -For a full list of callbacks and usage notes, see the {Sass::Plugin} documentation. - -{Sass::Plugin} also has a new method, -{Sass::Plugin#force_update_stylesheets force_update_stylesheets}. -This works just like {Sass::Plugin#update_stylesheets}, -except that it doesn't check modification times and doesn't use the cache; -all stylesheets are always compiled anew. - -### Output Formatting - -Properties with a value and *also* nested properties -are now rendered with the nested properties indented. -For example: - - margin: auto - top: 10px - bottom: 20px - -is now compiled to: - - margin: auto; - margin-top: 10px; - margin-bottom: 20px; - -#### `:compressed` Style - -When the `:compressed` style is used, -colors will be output as the minimal possible representation. -This means whichever is smallest of the HTML4 color name -and the hex representation (shortened to the three-letter version if possible). - -### Stylesheet Updating Speed - -Several caching layers were added to Sass's stylesheet updater. -This means that it should run significantly faster. -This benefit will be seen by people using Sass in development mode -with Rails, Rack, and Merb, -as well as people using `sass --watch` from the command line, -and to a lesser (but still significant) extent `sass --update`. -Thanks to [thedarkone](http://github.com/thedarkone). - -### Error Backtraces - -Numerous bugs were fixed with the backtraces given for Sass errors, -especially when importing files and using mixins. -All imports and mixins will now show up in the Ruby backtrace, -with the proper filename and line number. - -In addition, when the `sass` executable encounters an error, -it now prints the filename where the error occurs, -as well as a backtrace of Sass imports and mixins. - -### Ruby 1.9 Support - -* Sass and `css2sass` now produce more descriptive errors - when given a template with invalid byte sequences for that template's encoding, - including the line number and the offending character. - -* Sass and `css2sass` now accept Unicode documents with a - [byte-order-mark](http://en.wikipedia.org/wiki/Byte_order_mark). - -### Firebug Support - -A new {file:SASS_REFERENCE.md#debug_info-option `:debug_info` option} -has been added that emits line-number and filename information -to the CSS file in a browser-readable format. -This can be used with the new [FireSass Firebug extension](https://addons.mozilla.org/en-US/firefox/addon/103988) -to report the Sass filename and line number for generated CSS files. - -This is also available via the `--debug-info` command-line flag. - -### Minor Improvements - -* If a CSS or Sass function is used that has the name of a color, - it will now be parsed as a function rather than as a color. - For example, `fuchsia(12)` now renders as `fuchsia(12)` - rather than `fuchsia 12`, - and `tealbang(12)` now renders as `tealbang(12)` - rather than `teal bang(12)`. - -* The Sass Rails and Merb plugins now use Rack middleware by default. - -* Haml is now compatible with the [Rip](http://hellorip.com/) package management system. - Thanks to [Josh Peek](http://joshpeek.com/). - -* Indented-syntax `/*` comments may now include `*` on lines beyond the first. - -* A {file:SASS_REFERENCE.md#read_cache-option `:read_cache`} option has been added - to allow the Sass cache to be read from but not written to. - -* Stylesheets are no longer checked during each request - when running tests in Rails. - This should speed up some tests significantly. - -## 2.2.24 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.24). - -* Parent references -- the `&` character -- - may only be placed at the beginning of simple selector sequences in Sass 3. - Placing them elsewhere is deprecated in 2.2.24 and will print a warning. - For example, `foo &.bar` is allowed, but `foo .bar&` is not. - -## 2.2.23 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.23). - -* Don't crash when `rake gems` is run in Rails with Sass installed. - Thanks to [Florian Frank](http://github.com/flori). - -* When raising a file-not-found error, - add a list of load paths that were checked. - -* If an import isn't found for a cached Sass file and the - {file:SASS_REFERENCE.md#full_exception `:full_exception option`} is enabled, - print the full exception rather than raising it. - -* Fix a bug with a weird interaction with Haml, DataMapper, and Rails 3 - that caused some tag helpers to go into infinite recursion. - -## 2.2.22 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.22). - -* Add a railtie so Haml and Sass will be automatically loaded in Rails 3. - Thanks to [Daniel Neighman](http://pancakestacks.wordpress.com/). - -* Make loading the gemspec not crash on read-only filesystems like Heroku's. - -## 2.2.21 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.21). - -* Fix a few bugs in the git-revision-reporting in {Sass::Version#version}. - In particular, it will still work if `git gc` has been called recently, - or if various files are missing. - -* Always use `__FILE__` when reading files within the Haml repo in the `Rakefile`. - According to [this bug report](http://github.com/carlhuda/bundler/issues/issue/44), - this should make Sass work better with Bundler. - -## 2.2.20 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.20). - -* If the cache file for a given Sass file is corrupt - because it doesn't have enough content, - produce a warning and read the Sass file - rather than letting the exception bubble up. - This is consistent with other sorts of sassc corruption handling. - -* Calls to `defined?` shouldn't interfere with Rails' autoloading - in very old versions (1.2.x). - -## 2.2.19 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.18). - -There were no changes made to Sass between versions 2.2.18 and 2.2.19. - -## 2.2.18 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.18). - -* Use `Rails.env` rather than `RAILS_ENV` when running under Rails 3.0. - Thanks to [Duncan Grazier](http://duncangrazier.com/). - -* Support `:line_numbers` as an alias for {file:SASS_REFERENCE.md#line_numbers-option `:line_comments`}, - since that's what the docs have said forever. - Similarly, support `--line-numbers` as a command-line option. - -* Add a `--unix-newlines` flag to all executables - for outputting Unix-style newlines on Windows. - -* Add a {file:SASS_REFERENCE.md#unix_newlines-option `:unix_newlines` option} - for {Sass::Plugin} for outputting Unix-style newlines on Windows. - -* Fix the `--cache-location` flag, which was previously throwing errors. - Thanks to [tav](http://tav.espians.com/). - -* Allow comments at the beginning of the document to have arbitrary indentation, - just like comments elsewhere. - Similarly, comment parsing is a little nicer than before. - -## 2.2.17 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.16). - -* When the {file:SASS_REFERENCE.md#full_exception-option `:full_exception` option} - is false, raise the error in Ruby code rather than swallowing it - and printing something uninformative. - -* Fixed error-reporting when something goes wrong when loading Sass - using the `sass` executable. - This used to raise a NameError because `Sass::SyntaxError` wasn't defined. - Now it'll raise the correct exception instead. - -* Report the filename in warnings about selectors without properties. - -* `nil` values for Sass options are now ignored, - rather than raising errors. - -* Fix a bug that appears when Plugin template locations - have multiple trailing slashes. - Thanks to [Jared Grippe](http://jaredgrippe.com/). - -### Must Read! - -* When `@import` is given a filename without an extension, - the behavior of rendering a CSS `@import` if no Sass file is found - is deprecated. - In future versions, `@import foo` will either import the template - or raise an error. - -## 2.2.16 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.16). - -* Fixed a bug where modules containing user-defined Sass functions - weren't made available when simply included in {Sass::Script::Functions} - ({Sass::Script::Functions Functions} needed to be re-included in - {Sass::Script::Functions::EvaluationContext Functions::EvaluationContext}). - Now the module simply needs to be included in {Sass::Script::Functions}. - -## 2.2.15 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.15). - -* Added {Sass::Script::Color#with} for a way of setting color channels - that's easier than manually constructing a new color - and is forwards-compatible with alpha-channel colors - (to be introduced in Sass 2.4). - -* Added a missing require in Sass that caused crashes - when it was being run standalone. - -## 2.2.14 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.14). - -* All Sass functions now raise explicit errors if their inputs - are of the incorrect type. - -* Allow the SassScript `rgb()` function to take percentages - in addition to numerical values. - -* Fixed a bug where SassScript strings with `#` followed by `#{}` interpolation - didn't evaluate the interpolation. - -### SassScript Ruby API - -These changes only affect people defining their own Sass functions -using {Sass::Script::Functions}. - -* Sass::Script::Color#value attribute is deprecated. - Use {Sass::Script::Color#rgb} instead. - The returned array is now frozen as well. - -* Add an `assert_type` function that's available to {Sass::Script::Functions}. - This is useful for typechecking the inputs to functions. - -### Rack Support - -Sass 2.2.14 includes Rack middleware for running Sass, -meaning that all Rack-enabled frameworks can now use Sass. -To activate this, just add - - require 'sass/plugin/rack' - use Sass::Plugin::Rack - -to your `config.ru`. -See the {Sass::Plugin::Rack} documentation for more details. - -## 2.2.13 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.13). - -There were no changes made to Sass between versions 2.2.12 and 2.2.13. - -## 2.2.12 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.12). - -* Fix a stupid bug introduced in 2.2.11 that broke the Sass Rails plugin. - -## 2.2.11 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.11). - -* Added a note to errors on properties that could be pseudo-classes (e.g. `:focus`) - indicating that they should be backslash-escaped. - -* Automatically interpret properties that could be pseudo-classes as such - if {file:SASS_REFERENCE.md.html#property_syntax-option `:property_syntax`} - is set to `:new`. - -* Fixed `css2sass`'s generation of pseudo-classes so that they're backslash-escaped. - -* Don't crash if the Haml plugin skeleton is installed and `rake gems:install` is run. - -* Don't use `RAILS_ROOT` directly. - This no longer exists in Rails 3.0. - Instead abstract this out as `Haml::Util.rails_root`. - This changes makes Haml fully compatible with edge Rails as of this writing. - -* Make use of a Rails callback rather than a monkeypatch to check for stylesheet updates - in Rails 3.0+. - -## 2.2.10 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.10). - -* Add support for attribute selectors with spaces around the `=`. - For example: - - a[href = http://google.com] - color: blue - -## 2.2.9 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.9). - -There were no changes made to Sass between versions 2.2.8 and 2.2.9. - -## 2.2.8 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.8). - -There were no changes made to Sass between versions 2.2.7 and 2.2.8. - -## 2.2.7 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.7). - -There were no changes made to Sass between versions 2.2.6 and 2.2.7. - -## 2.2.6 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.6). - -* Don't crash when the `__FILE__` constant of a Ruby file is a relative path, - as apparently happens sometimes in TextMate - (thanks to [Karl Varga](http://github.com/kjvarga)). - -* Add "Sass" to the `--version` string for the executables. - -## 2.2.5 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.5). - -There were no changes made to Sass between versions 2.2.4 and 2.2.5. - -## 2.2.4 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.4). - -* Don't add `require 'rubygems'` to the top of init.rb when installed - via `sass --rails`. This isn't necessary, and actually gets - clobbered as soon as haml/template is loaded. - -* Document the previously-undocumented {file:SASS_REFERENCE.md#line-option `:line` option}, - which allows the number of the first line of a Sass file to be set for error reporting. - -## 2.2.3 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.3). - -Sass 2.2.3 prints line numbers for warnings about selectors -with no properties. - -## 2.2.2 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.2). - -Sass 2.2.2 is a minor bug-fix release. -Notable changes include better parsing of mixin definitions and inclusions -and better support for Ruby 1.9. - -## 2.2.1 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.1). - -Sass 2.2.1 is a minor bug-fix release. - -### Must Read! - -* It used to be acceptable to use `-` immediately following variable names, - without any whitespace in between (for example, `!foo-!bar`). - This is now deprecated, so that in the future variables with hyphens - can be supported. Surround `-` with spaces. - -## 2.2.0 - -[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.0). - -The 2.2 release marks a significant step in the evolution of the Sass -language. The focus has been to increase the power of Sass to keep -your stylesheets maintainable by allowing new forms of abstraction to -be created within your stylesheets and the stylesheets provided by -others that you can download and import into your own. The fundamental -units of abstraction in Sass are variables and mixins. Please read -below for a list of changes: - -### Must Read! - -* Sass Comments (//) used to only comment out a single line. This was deprecated - in 2.0.10 and starting in 2.2, Sass comments will comment out any lines indented - under them. Upgrade to 2.0.10 in order to see deprecation warnings where this change - affects you. - -* Implicit Strings within SassScript are now deprecated and will be removed in 2.4. - For example: `border= !width solid #00F` should now be written as `border: #{!width} solid #00F` - or as `border= !width "solid" #00F`. After upgrading to 2.2, you will see deprecation warnings - if you have sass files that use implicit strings. - - -### Sass Syntax Changes - -#### Flexible Indentation - -The indentation of Sass documents is now flexible. The first indent -that is detected will determine the indentation style for that -document. Tabs and spaces may never be mixed, but within a document, -you may choose to use tabs or a flexible number of spaces. - -#### Multiline Sass Comments - -Sass Comments (//) will now comment out whatever is indented beneath -them. Previously they were single line when used at the top level of a -document. Upgrading to the latest stable version will give you -deprecation warnings if you have silent comments with indentation -underneath them. - -#### Mixin Arguments - -Sass Mixins now accept any number of arguments. To define a mixin with -arguments, specify the arguments as a comma-delimited list of -variables like so: - - =my-mixin(!arg1, !arg2, !arg3) - -As before, the definition of the mixin is indented below the mixin -declaration. The variables declared in the argument list may be used -and will be bound to the values passed to the mixin when it is -invoked. Trailing arguments may have default values as part of the -declaration: - - =my-mixin(!arg1, !arg2 = 1px, !arg3 = blue) - -In the example above, the mixin may be invoked by passing 1, 2 or 3 -arguments to it. A similar syntax is used to invoke a mixin that -accepts arguments: - - div.foo - +my-mixin(1em, 3px) - -When a mixin has no required arguments, the parenthesis are optional. - -The default values for mixin arguments are evaluated in the global -context at the time when the mixin is invoked, they may also reference -the previous arguments in the declaration. For example: - - !default_width = 30px - =my-fancy-mixin(!width = !default_width, !height = !width) - width= !width - height= !height - - .default-box - +my-fancy-mixin - - .square-box - +my-fancy-mixin(50px) - - .rectangle-box - +my-fancy-mixin(25px, 75px) - - !default_width = 10px - .small-default-box - +my-fancy-mixin - - -compiles to: - - .default-box { - width: 30px; - height: 30px; } - - .square-box { - width: 50px; - height: 50px; } - - .rectangle-box { - width: 25px; - height: 75px; } - - .small-default-box { - width: 10px; - height: 10px; } - - -### Sass, Interactive - -The sass command line option -i now allows you to quickly and -interactively experiment with SassScript expressions. The value of the -expression you enter will be printed out after each line. Example: - - $ sass -i - >> 5px - 5px - >> 5px + 10px - 15px - >> !five_pixels = 5px - 5px - >> !five_pixels + 10px - 15px - -### SassScript - -The features of SassScript have been greatly enhanced with new control -directives, new fundamental data types, and variable scoping. - -#### New Data Types - -SassScript now has four fundamental data types: - -1. Number -2. String -3. Boolean (New in 2.2) -4. Colors - -#### More Flexible Numbers - -Like JavaScript, SassScript numbers can now change between floating -point and integers. No explicit casting or decimal syntax is -required. When a number is emitted into a CSS file it will be rounded -to the nearest thousandth, however the internal representation -maintains much higher precision. - -#### Improved Handling of Units - -While Sass has long supported numbers with units, it now has a much -deeper understanding of them. The following are examples of legal -numbers in SassScript: - - 0, 1000, 6%, -2px, 5pc, 20em, or 2foo. - -Numbers of the same unit may always be added and subtracted. Numbers -that have units that Sass understands and finds comparable, can be -combined, taking the unit of the first number. Numbers that have -non-comparable units may not be added nor subtracted -- any attempt to -do so will cause an error. However, a unitless number takes on the -unit of the other number during a mathematical operation. For example: - - >> 3mm + 4cm - 43mm - >> 4cm + 3mm - 4.3cm - >> 3cm + 2in - 8.08cm - >> 5foo + 6foo - 11foo - >> 4% + 5px - SyntaxError: Incompatible units: 'px' and '%'. - >> 5 + 10px - 15px - -Sass allows compound units to be stored in any intermediate form, but -will raise an error if you try to emit a compound unit into your css -file. - - >> !em_ratio = 1em / 16px - 0.063em/px - >> !em_ratio * 32px - 2em - >> !em_ratio * 40px - 2.5em - -#### Colors - -A color value can be declared using a color name, hexadecimal, -shorthand hexadecimal, the rgb function, or the hsl function. When -outputting a color into css, the color name is used, if any, otherwise -it is emitted as hexadecimal value. Examples: - - > #fff - white - >> white - white - >> #FFFFFF - white - >> hsl(180, 100, 100) - white - >> rgb(255, 255, 255) - white - >> #AAA - #aaaaaa - -Math on color objects is performed piecewise on the rgb -components. However, these operations rarely have meaning in the -design domain (mostly they make sense for gray-scale colors). - - >> #aaa + #123 - #bbccdd - >> #333 * 2 - #666666 - -#### Booleans - -Boolean objects can be created by comparison operators or via the -`true` and `false` keywords. Booleans can be combined using the -`and`, `or`, and `not` keywords. - - >> true - true - >> true and false - false - >> 5 < 10 - true - >> not (5 < 10) - false - >> not (5 < 10) or not (10 < 5) - true - >> 30mm == 3cm - true - >> 1px == 1em - false - -#### Strings - -Unicode escapes are now allowed within SassScript strings. - -### Control Directives - -New directives provide branching and looping within a sass stylesheet -based on SassScript expressions. See the [Sass -Reference](SASS_REFERENCE.md.html#control_directives) for complete -details. - -#### @for - -The `@for` directive loops over a set of numbers in sequence, defining -the current number into the variable specified for each loop. The -`through` keyword means that the last iteration will include the -number, the `to` keyword means that it will stop just before that -number. - - @for !x from 1px through 5px - .border-#{!x} - border-width= !x - -compiles to: - - .border-1px { - border-width: 1px; } - - .border-2px { - border-width: 2px; } - - .border-3px { - border-width: 3px; } - - .border-4px { - border-width: 4px; } - - .border-5px { - border-width: 5px; } - -#### @if / @else if / @else - -The branching directives `@if`, `@else if`, and `@else` let you select -between several branches of sass to be emitted, based on the result of -a SassScript expression. Example: - - !type = "monster" - p - @if !type == "ocean" - color: blue - @else if !type == "matador" - color: red - @else if !type == "monster" - color: green - @else - color: black - -is compiled to: - - p { - color: green; } - -#### @while - -The `@while` directive lets you iterate until a condition is -met. Example: - - !i = 6 - @while !i > 0 - .item-#{!i} - width = 2em * !i - !i = !i - 2 - -is compiled to: - - .item-6 { - width: 12em; } - - .item-4 { - width: 8em; } - - .item-2 { - width: 4em; } - -### Variable Scoping - -The term "constant" has been renamed to "variable." Variables can be -declared at any scope (a.k.a. nesting level) and they will only be -visible to the code until the next outdent. However, if a variable is -already defined in a higher level scope, setting it will overwrite the -value stored previously. - -In this code, the `!local_var` variable is scoped and hidden from -other higher level scopes or sibling scopes: - - .foo - .bar - !local_var = 1px - width= !local_var - .baz - // this will raise an undefined variable error. - width= !local_var - // as will this - width= !local_var - -In this example, since the `!global_var` variable is first declared at -a higher scope, it is shared among all lower scopes: - - !global_var = 1px - .foo - .bar - !global_var = 2px - width= !global_var - .baz - width= !global_var - width= !global_var - -compiles to: - - .foo { - width: 2px; } - .foo .bar { - width: 2px; } - .foo .baz { - width: 2px; } - - -### Interpolation - -Interpolation has been added. This allows SassScript to be used to -create dynamic properties and selectors. It also cleans up some uses -of dynamic values when dealing with compound properties. Using -interpolation, the result of a SassScript expression can be placed -anywhere: - - !x = 1 - !d = 3 - !property = "border" - div.#{!property} - #{!property}: #{!x + !d}px solid - #{!property}-color: blue - -is compiled to: - - div.border { - border: 4px solid; - border-color: blue; } - -### Sass Functions - -SassScript defines some useful functions that are called using the -normal CSS function syntax: - - p - color = hsl(0, 100%, 50%) - -is compiled to: - - #main { - color: #ff0000; } - -The following functions are provided: `hsl`, `percentage`, `round`, -`ceil`, `floor`, and `abs`. You can define additional functions in -ruby. - -See {Sass::Script::Functions} for more information. - - -### New Options - -#### `:line_comments` - -To aid in debugging, You may set the `:line_comments` option to -`true`. This will cause the sass engine to insert a comment before -each selector saying where that selector was defined in your sass -code. - -#### `:template_location` - -The {Sass::Plugin} `:template_location` option now accepts a hash of -sass paths to corresponding css paths. Please be aware that it is -possible to import sass files between these separate locations -- they -are not isolated from each other. - -### Miscellaneous Features - -#### `@debug` Directive - -The `@debug` directive accepts a SassScript expression and emits the -value of that expression to the terminal (stderr). - -Example: - - @debug 1px + 2px - -During compilation the following will be printed: - - Line 1 DEBUG: 3px - -#### Ruby 1.9 Support - -Sass now fully supports Ruby 1.9.1. - -#### Sass Cache - -By default, Sass caches compiled templates and -[partials](SASS_REFERENCE.md.html#partials). This dramatically speeds -up re-compilation of large collections of Sass files, and works best -if the Sass templates are split up into separate files that are all -[`@import`](SASS_REFERENCE.md.html#import)ed into one large file. - -Without a framework, Sass puts the cached templates in the -`.sass-cache` directory. In Rails and Merb, they go in -`tmp/sass-cache`. The directory can be customized with the -[`:cache_location`](#cache_location-option) option. If you don't want -Sass to use caching at all, set the [`:cache`](#cache-option) option -to `false`. diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SASS_REFERENCE.md b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SASS_REFERENCE.md deleted file mode 100644 index 736be16a2b..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SASS_REFERENCE.md +++ /dev/null @@ -1,1957 +0,0 @@ -# Sass (Syntactically Awesome StyleSheets) - -* Table of contents -{:toc} - -Sass is an extension of CSS -that adds power and elegance to the basic language. -It allows you to use [variables](#variables_), [nested rules](#nested_rules), -[mixins](#mixins), [inline imports](#import), and more, -all with a fully CSS-compatible syntax. -Sass helps keep large stylesheets well-organized, -and get small stylesheets up and running quickly, -particularly with the help of -[the Compass style library](http://compass-style.org). - -## Features - -* Fully CSS3-compatible -* Language extensions such as variables, nesting, and mixins -* Many {Sass::Script::Functions useful functions} for manipulating colors and other values -* Advanced features like [control directives](#control_directives) for libraries -* Well-formatted, customizable output -* [Firebug integration](https://addons.mozilla.org/en-US/firefox/addon/103988) - -## Syntax - -There are two syntaxes available for Sass. -The first, known as SCSS (Sassy CSS) and used throughout this reference, -is an extension of the syntax of CSS3. -This means that every valid CSS3 stylesheet -is a valid SCSS file with the same meaning. -In addition, SCSS understands most CSS hacks -and vendor-specific syntax, such as [IE's old `filter` syntax](http://msdn.microsoft.com/en-us/library/ms533754%28VS.85%29.aspx). -This syntax is enhanced with the Sass features described below. -Files using this syntax have the `.scss` extension. - -The second and older syntax, known as the indented syntax (or sometimes just "Sass"), -provides a more concise way of writing CSS. -It uses indentation rather than brackets to indicate nesting of selectors, -and newlines rather than semicolons to separate properties. -Some people find this to be easier to read and quicker to write than SCSS. -The indented syntax has all the same features, -although some of them have slightly different syntax; -this is described in {file:INDENTED_SYNTAX.md the indented syntax reference}. -Files using this syntax have the `.sass` extension. - -Either syntax can [import](#import) files written in the other. -Files can be automatically converted from one syntax to the other -using the `sass-convert` command line tool: - - # Convert Sass to SCSS - $ sass-convert style.sass style.scss - - # Convert SCSS to Sass - $ sass-convert style.scss style.sass - -## Using Sass - -Sass can be used in three ways: -as a command-line tool, -as a standalone Ruby module, -and as a plugin for any Rack-enabled framework, -including Ruby on Rails and Merb. -The first step for all of these is to install the Sass gem: - - gem install sass - -If you're using Windows, -you may need to [install Ruby](http://rubyinstaller.org/download.html) first. - -To run Sass from the command line, just use - - sass input.scss output.css - -You can also tell Sass to watch the file and update the CSS -every time the Sass file changes: - - sass --watch input.scss:output.css - -If you have a directory with many Sass files, -you can also tell Sass to watch the entire directory: - - sass --watch app/sass:public/stylesheets - -Use `sass --help` for full documentation. - -Using Sass in Ruby code is very simple. -After installing the Sass gem, -you can use it by running `require "sass"` -and using {Sass::Engine} like so: - - engine = Sass::Engine.new("#main {background-color: #0000ff}", :syntax => :scss) - engine.render #=> "#main { background-color: #0000ff; }\n" - -### Rack/Rails/Merb Plugin - -To enable Sass in Rails versions before Rails 3, -add the following line to `environment.rb`: - - config.gem "sass" - -For Rails 3, instead add the following line to the Gemfile: - - gem "sass" - -To enable Sass in Merb, -add the following line to `config/dependencies.rb`: - - dependency "merb-haml" - -To enable Sass in a Rack application, -add - - require 'sass/plugin/rack' - use Sass::Plugin::Rack - -to `config.ru`. - -Sass stylesheets don't work the same as views. -They don't contain dynamic content, -so the CSS only needs to be generated when the Sass file has been updated. -By default, `.sass` and `.scss` files are placed in public/stylesheets/sass -(this can be customized with the [`:template_location`](#template_location-option) option). -Then, whenever necessary, they're compiled into corresponding CSS files in public/stylesheets. -For instance, public/stylesheets/sass/main.scss would be compiled to public/stylesheets/main.css. - -### Caching - -By default, Sass caches compiled templates and [partials](#partials). -This dramatically speeds up re-compilation of large collections of Sass files, -and works best if the Sass templates are split up into separate files -that are all [`@import`](#import)ed into one large file. - -Without a framework, Sass puts the cached templates in the `.sass-cache` directory. -In Rails and Merb, they go in `tmp/sass-cache`. -The directory can be customized with the [`:cache_location`](#cache_location-option) option. -If you don't want Sass to use caching at all, -set the [`:cache`](#cache-option) option to `false`. - -### Options - -Options can be set by setting the {Sass::Plugin::Configuration#options Sass::Plugin#options} hash -in `environment.rb` in Rails or `config.ru` in Rack... - - Sass::Plugin.options[:style] = :compact - -...or by setting the `Merb::Plugin.config[:sass]` hash in `init.rb` in Merb... - - Merb::Plugin.config[:sass][:style] = :compact - -...or by passing an options hash to {Sass::Engine#initialize}. -All relevant options are also available via flags -to the `sass` and `scss` command-line executables. -Available options are: - -{#style-option} `:style` -: Sets the style of the CSS output. - See [Output Style](#output_style). - -{#syntax-option} `:syntax` -: The syntax of the input file, `:sass` for the indented syntax - and `:scss` for the CSS-extension syntax. - This is only useful when you're constructing {Sass::Engine} instances yourself; - it's automatically set properly when using {Sass::Plugin}. - Defaults to `:sass`. - -{#property_syntax-option} `:property_syntax` -: Forces indented-syntax documents to use one syntax for properties. - If the correct syntax isn't used, an error is thrown. - `:new` forces the use of a colon or equals sign - after the property name. - For example: `color: #0f3` - or `width: $main_width`. - `:old` forces the use of a colon - before the property name. - For example: `:color #0f3` - or `:width $main_width`. - By default, either syntax is valid. - This has no effect on SCSS documents. - -{#cache-option} `:cache` -: Whether parsed Sass files should be cached, - allowing greater speed. Defaults to true. - -{#read_cache-option} `:read_cache` -: If this is set and `:cache` is not, - only read the Sass cache if it exists, - don't write to it if it doesn't. - -{#cache_store-option} `:cache_store` -: If this is set to an instance of a subclass of {Sass::CacheStores::Base}, - that cache store will be used to store and retrieve - cached compilation results. - Defaults to a {Sass::CacheStores::Filesystem} that is - initialized using the [`:cache_location` option](#cache_location-option). - -{#never_update-option} `:never_update` -: Whether the CSS files should never be updated, - even if the template file changes. - Setting this to true may give small performance gains. - It always defaults to false. - Only has meaning within Rack, Ruby on Rails, or Merb. - -{#always_update-option} `:always_update` -: Whether the CSS files should be updated every - time a controller is accessed, - as opposed to only when the template has been modified. - Defaults to false. - Only has meaning within Rack, Ruby on Rails, or Merb. - -{#always_check-option} `:always_check` -: Whether a Sass template should be checked for updates every - time a controller is accessed, - as opposed to only when the server starts. - If a Sass template has been updated, - it will be recompiled and will overwrite the corresponding CSS file. - Defaults to false in production mode, true otherwise. - Only has meaning within Rack, Ruby on Rails, or Merb. - -{#full_exception-option} `:full_exception` -: Whether an error in the Sass code - should cause Sass to provide a detailed description - within the generated CSS file. - If set to true, the error will be displayed - along with a line number and source snippet - both as a comment in the CSS file - and at the top of the page (in supported browsers). - Otherwise, an exception will be raised in the Ruby code. - Defaults to false in production mode, true otherwise. - Only has meaning within Rack, Ruby on Rails, or Merb. - -{#template_location-option} `:template_location` -: A path to the root sass template directory for your application. - If a hash, `:css_location` is ignored and this option designates - a mapping between input and output directories. - May also be given a list of 2-element lists, instead of a hash. - Defaults to `css_location + "/sass"`. - Only has meaning within Rack, Ruby on Rails, or Merb. - Note that if multiple template locations are specified, all - of them are placed in the import path, allowing you to import - between them. - **Note that due to the many possible formats it can take, - this option should only be set directly, not accessed or modified. - Use the {Sass::Plugin::Configuration#template_location_array Sass::Plugin#template_location_array}, - {Sass::Plugin::Configuration#add_template_location Sass::Plugin#add_template_location}, - and {Sass::Plugin::Configuration#remove_template_location Sass::Plugin#remove_template_location} methods instead**. - -{#css_location-option} `:css_location` -: The path where CSS output should be written to. - This option is ignored when `:template_location` is a Hash. - Defaults to `"./public/stylesheets"`. - Only has meaning within Rack, Ruby on Rails, or Merb. - -{#cache_location-option} `:cache_location` -: The path where the cached `sassc` files should be written to. - Defaults to `"./tmp/sass-cache"` in Rails and Merb, - or `"./.sass-cache"` otherwise. - If the [`:cache_store` option](#cache_location-option) is set, - this is ignored. - -{#unix_newlines-option} `:unix_newlines` -: If true, use Unix-style newlines when writing files. - Only has meaning on Windows, and only when Sass is writing the files - (in Rack, Rails, or Merb, when using {Sass::Plugin} directly, - or when using the command-line executable). - -{#filename-option} `:filename` -: The filename of the file being rendered. - This is used solely for reporting errors, - and is automatically set when using Rack, Rails, or Merb. - -{#line-option} `:line` -: The number of the first line of the Sass template. - Used for reporting line numbers for errors. - This is useful to set if the Sass template is embedded in a Ruby file. - -{#load_paths-option} `:load_paths` -: An array of filesystem paths or importers which should be searched - for Sass templates imported with the [`@import`](#import) directive. - These may be strings, `Pathname` objects, or subclasses of {Sass::Importers::Base}. - This defaults to the working directory and, in Rack, Rails, or Merb, - whatever `:template_location` is. - -{#filesystem_importer-option} `:filesystem_importer` -: A {Sass::Importers::Base} subclass used to handle plain string load paths. - This should import files from the filesystem. - It should be a Class object inheriting from {Sass::Importers::Base} - with a constructor that takes a single string argument (the load path). - Defaults to {Sass::Importers::Filesystem}. - -{#line_numbers-option} `:line_numbers` -: When set to true, causes the line number and file - where a selector is defined to be emitted into the compiled CSS - as a comment. Useful for debugging, especially when using imports - and mixins. - This option may also be called `:line_comments`. - Automatically disabled when using the `:compressed` output style - or the `:debug_info` option. - -{#debug_info-option} `:debug_info` -: When set to true, causes the line number and file - where a selector is defined to be emitted into the compiled CSS - in a format that can be understood by the browser. - Useful in conjunction with [the FireSass Firebug extension](https://addons.mozilla.org/en-US/firefox/addon/103988) - for displaying the Sass filename and line number. - Automatically disabled when using the `:compressed` output style. - -{#custom-option} `:custom` -: An option that's available for individual applications to set - to make data available to {Sass::Script::Functions custom Sass functions}. - -{#quiet-option} `:quiet` -: When set to true, causes warnings to be disabled. - -### Syntax Selection - -The Sass command-line tool will use the file extension to determine which -syntax you are using, but there's not always a filename. The `sass` -command-line program defaults to the indented syntax but you can pass the -`--scss` option to it if the input should be interpreted as SCSS syntax. -Alternatively, you can use the `scss` command-line program which is exactly -like the `sass` program but it defaults to assuming the syntax is SCSS. - -### Encodings - -When running on Ruby 1.9 and later, Sass is aware of the character encoding of documents -and will handle them the same way that CSS would. -By default, Sass assumes that all stylesheets are encoded -using whatever coding system your operating system defaults to. -For many users this will be `UTF-8`, the de facto standard for the web. -For some users, though, it may be a more local encoding. - -If you want to use a different encoding for your stylesheet -than your operating system default, -you can use the `@charset` declaration just like in CSS. -Add `@charset "encoding-name";` at the beginning of the stylesheet -(before any whitespace or comments) -and Sass will interpret it as the given encoding. -Note that whatever encoding you use, it must be convertible to Unicode. - -Sass will also respect any Unicode BOMs and non-ASCII-compatible Unicode encodings -[as specified by the CSS spec](http://www.w3.org/TR/CSS2/syndata.html#charset), -although this is *not* the recommended way -to specify the character set for a document. -Note that Sass does not support the obscure `UTF-32-2143`, -`UTF-32-3412`, `EBCDIC`, `IBM1026`, and `GSM 03.38` encodings, -since Ruby does not have support for them -and they're highly unlikely to ever be used in practice. - -#### Output Encoding - -In general, Sass will try to encode the output stylesheet -using the same encoding as the input stylesheet. -In order for it to do this, though, the input stylesheet must have a `@charset` declaration; -otherwise, Sass will default to encoding the output stylesheet as UTF-8. -In addition, it will add a `@charset` declaration to the output -if it's not plain ASCII. - -When other stylesheets with `@charset` declarations are `@import`ed, -Sass will convert them to the same encoding as the main stylesheet. - -Note that Ruby 1.8 does not have good support for character encodings, -and so Sass behaves somewhat differently when running under it than under Ruby 1.9 and later. -In Ruby 1.8, Sass simply uses the first `@charset` declaration in the stylesheet -or any of the other stylesheets it `@import`s. - -## CSS Extensions - -### Nested Rules - -Sass allows CSS rules to be nested within one another. -The inner rule then only applies within the outer rule's selector. -For example: - - #main p { - color: #00ff00; - width: 97%; - - .redbox { - background-color: #ff0000; - color: #000000; - } - } - -is compiled to: - - #main p { - color: #00ff00; - width: 97%; } - #main p .redbox { - background-color: #ff0000; - color: #000000; } - -This helps avoid repetition of parent selectors, -and makes complex CSS layouts with lots of nested selectors much simpler. -For example: - - #main { - width: 97%; - - p, div { - font-size: 2em; - a { font-weight: bold; } - } - - pre { font-size: 3em; } - } - -is compiled to: - - #main { - width: 97%; } - #main p, #main div { - font-size: 2em; } - #main p a, #main div a { - font-weight: bold; } - #main pre { - font-size: 3em; } - -### Referencing Parent Selectors: `&` - -Sometimes it's useful to use a nested rule's parent selector -in other ways than the default. -For instance, you might want to have special styles -for when that selector is hovered over -or for when the body element has a certain class. -In these cases, you can explicitly specify where the parent selector -should be inserted using the `&` character. -For example: - - a { - font-weight: bold; - text-decoration: none; - &:hover { text-decoration: underline; } - body.firefox & { font-weight: normal; } - } - -is compiled to: - - a { - font-weight: bold; - text-decoration: none; } - a:hover { - text-decoration: underline; } - body.firefox a { - font-weight: normal; } - -`&` will be replaced with the parent selector as it appears in the CSS. -This means that if you have a deeply nested rule, -the parent selector will be fully resolved -before the `&` is replaced. -For example: - - #main { - color: black; - a { - font-weight: bold; - &:hover { color: red; } - } - } - -is compiled to: - - #main { - color: black; } - #main a { - font-weight: bold; } - #main a:hover { - color: red; } - -### Nested Properties - -CSS has quite a few properties that are in "namespaces;" -for instance, `font-family`, `font-size`, and `font-weight` -are all in the `font` namespace. -In CSS, if you want to set a bunch of properties in the same namespace, -you have to type it out each time. -Sass provides a shortcut for this: -just write the namespace one, -then nest each of the sub-properties within it. -For example: - - .funky { - font: { - family: fantasy; - size: 30em; - weight: bold; - } - } - -is compiled to: - - .funky { - font-family: fantasy; - font-size: 30em; - font-weight: bold; } - -The property namespace itself can also have a value. -For example: - - .funky { - font: 2px/3px { - family: fantasy; - size: 30em; - weight: bold; - } - } - -is compiled to: - - .funky { - font: 2px/3px; - font-family: fantasy; - font-size: 30em; - font-weight: bold; } - -## Comments: `/* */` and `//` {#comments} - -Sass supports standard multiline CSS comments with `/* */`, -as well as single-line comments with `//`. -The multiline comments are preserved in the CSS output where possible, -while the single-line comments are removed. -For example: - - /* This comment is - * several lines long. - * since it uses the CSS comment syntax, - * it will appear in the CSS output. */ - body { color: black; } - - // These comments are only one line long each. - // They won't appear in the CSS output, - // since they use the single-line comment syntax. - a { color: green; } - -is compiled to: - - /* This comment is - * several lines long. - * since it uses the CSS comment syntax, - * it will appear in the CSS output. */ - body { - color: black; } - - a { - color: green; } - -When the first letter of a comment is `!`, the comment will be interpolated -and always rendered into css output even in compressed output modes. This is useful for adding Copyright notices to your generated CSS. - -## SassScript {#sassscript} - -In addition to the plain CSS property syntax, -Sass supports a small set of extensions called SassScript. -SassScript allows properties to use -variables, arithmetic, and extra functions. -SassScript can be used in any property value. - -SassScript can also be used to generate selectors and property names, -which is useful when writing [mixins](#mixins). -This is done via [interpolation](#interpolation_). - -### Interactive Shell - -You can easily experiment with SassScript using the interactive shell. -To launch the shell run the sass command-line with the `-i` option. At the -prompt, enter any legal SassScript expression to have it evaluated -and the result printed out for you: - - $ sass -i - >> "Hello, Sassy World!" - "Hello, Sassy World!" - >> 1px + 1px + 1px - 3px - >> #777 + #777 - #eeeeee - >> #777 + #888 - white - -### Variables: `$` {#variables_} - -The most straightforward way to use SassScript -is to use variables. -Variables begin with dollar signs, -and are set like CSS properties: - - $width: 5em; - -You can then refer to them in properties: - - #main { - width: $width; - } - -Variables are only available within the level of nested selectors -where they're defined. -If they're defined outside of any nested selectors, -they're available everywhere. - -Variables used to use the prefix character `!`; -this still works, but it's deprecated and prints a warning. -`$` is the recommended syntax. - -Variables also used to be defined with `=` rather than `:`; -this still works, but it's deprecated and prints a warning. -`:` is the recommended syntax. - -### Data Types - -SassScript supports four main data types: - -* numbers (e.g. `1.2`, `13`, `10px`) -* strings of text, with and without quotes (e.g. `"foo"`, `'bar'`, `baz`) -* colors (e.g. `blue`, `#04a3f9`, `rgba(255, 0, 0, 0.5)`) -* booleans (e.g. `true`, `false`) -* lists of values, separated by spaces or commas (e.g. `1.5em 1em 0 2em`, `Helvetica, Arial, sans-serif`) - -SassScript also supports all other types of CSS property value, -such as Unicode ranges and `!important` declarations. -However, it has no special handling for these types. -They're treated just like unquoted strings. - -#### Strings {#sass-script-strings} - -CSS specifies two kinds of strings: those with quotes, -such as `"Lucida Grande"` or `'http://sass-lang.com'`, -and those without quotes, such as `sans-serif` or `bold`. -SassScript recognizes both kinds, -and in general if one kind of string is used in the Sass document, -that kind of string will be used in the resulting CSS. - -There is one exception to this, though: -when using [`#{}` interpolation](#interpolation_), -quoted strings are unquoted. -This makes it easier to use e.g. selector names in [mixins](#mixins). -For example: - - @mixin firefox-message($selector) { - body.firefox #{$selector}:before { - content: "Hi, Firefox users!"; } } - - @include firefox-message(".header"); - -is compiled to: - - body.firefox .header:before { - content: "Hi, Firefox users!"; } - -It's also worth noting that when using the [deprecated `=` property syntax](#sassscript), -all strings are interpreted as unquoted, -regardless of whether or not they're written with quotes. - -#### Lists - -Lists are how Sass represents the values of CSS declarations -like `margin: 10px 15px 0 0` or `font-face: Helvetica, Arial, sans-serif`. -Lists are just a series of other values, separated by either spaces or commas. -In fact, individual values count as lists, too: they're just lists with one item. - -On their own, lists don't do much, -but the {file:Sass/Script/Functions.html#list-functions Sass list functions} -make them useful. -The {Sass::Script::Functions#nth nth function} can access items in a list, -the {Sass::Script::Functions#join join function} can join multiple lists together, -and the {Sass::Script::Functions#append append function} can add items to lists. -The [`@each` rule](#each-directive) can also add styles for each item in a list. - -In addition to containing simple values, lists can contain other lists. -For example, `1px 2px, 5px 6px` is a two-item list -containing the list `1px 2px` and the list `5px 6px`. -If the inner lists have the same separator as the outer list, -you'll need to use parentheses to make it clear -where the inner lists start and stop. -For example, `(1px 2px) (5px 6px)` is also a two-item list -containing the list `1px 2px` and the list `5px 6px`. -The difference is that the outer list is space-separated, -where before it was comma-separated. - -When lists are turned into plain CSS, Sass doesn't add any parentheses, -since CSS doesn't understand them. -That means that `(1px 2px) (5px 6px)` and `1px 2px 5px 6px` -will look the same when they become CSS. -However, they aren't the same when they're Sass: -the first is a list containing two lists, -while the second is a list containing four numbers. - -Lists can also have no items in them at all. -These lists are represented as `()`. -They can't be output directly to CSS; -if you try to do e.g. `font-family: ()`, Sass will raise an error. -If a list contains empty lists, as in `1px 2px () 3px`, -the empty list will be removed before it's turned into CSS. - -### Operations - -All types support equality operations (`==` and `!=`). -In addition, each type has its own operations -that it has special support for. - -#### Number Operations - -SassScript supports the standard arithmetic operations on numbers -(`+`, `-`, `*`, `/`, `%`), -and will automatically convert between units if it can: - - p { - width: 1in + 8pt; - } - -is compiled to: - - p { - width: 1.111in; } - -Relational operators -(`<`, `>`, `<=`, `>=`) -are also supported for numbers, -and equality operators -(`==`, `!=`) -are supported for all types. - -##### Division and `/` -{#division-and-slash} - -CSS allows `/` to appear in property values -as a way of separating numbers. -Since SassScript is an extension of the CSS property syntax, -it must support this, while also allowing `/` to be used for division. -This means that by default, if two numbers are separated by `/` in SassScript, -then they will appear that way in the resulting CSS. - -However, there are three situations where the `/` will be interpreted as division. -These cover the vast majority of cases where division is actually used. -They are: - -1. If the value, or any part of it, is stored in a variable. -2. If the value is surrounded by parentheses. -3. If the value is used as part of another arithmetic expression. - -For example: - - p { - font: 10px/8px; // Plain CSS, no division - $width: 1000px; - width: $width/2; // Uses a variable, does division - height: (500px/2); // Uses parentheses, does division - margin-left: 5px + 8px/2px; // Uses +, does division - } - -is compiled to: - - p { - font: 10px/8px; - width: 500px; - height: 250px; - margin-left: 9px; } - -If you want to use variables along with a plain CSS `/`, -you can use `#{}` to insert them. -For example: - - p { - $font-size: 12px; - $line-height: 30px; - font: #{$font-size}/#{$line-height}; - } - -is compiled to: - - p { - font: 12px/30px; - } - -#### Color Operations - -All arithmetic operations are supported for color values, -where they work piecewise. -This means that the operation is performed -on the red, green, and blue components in turn. -For example: - - p { - color: #010203 + #040506; - } - -computes `01 + 04 = 05`, `02 + 05 = 07`, and `03 + 06 = 09`, -and is compiled to: - - p { - color: #050709; } - -Often it's more useful to use {Sass::Script::Functions color functions} -than to try to use color arithmetic to achieve the same effect. - -Arithmetic operations also work between numbers and colors, -also piecewise. -For example: - - p { - color: #010203 * 2; - } - -computes `01 * 2 = 02`, `02 * 2 = 04`, and `03 * 2 = 06`, -and is compiled to: - - p { - color: #020406; } - -Note that colors with an alpha channel -(those created with the {Sass::Script::Functions#rgba rgba} -or {Sass::Script::Functions#hsla hsla} functions) -must have the same alpha value in order for color arithmetic -to be done with them. -The arithmetic doesn't affect the alpha value. -For example: - - p { - color: rgba(255, 0, 0, 0.75) + rgba(0, 255, 0, 0.75); - } - -is compiled to: - - p { - color: rgba(255, 255, 0, 0.75); } - -The alpha channel of a color can be adjusted using the -{Sass::Script::Functions#opacify opacify} and -{Sass::Script::Functions#transparentize transparentize} functions. -For example: - - $translucent-red: rgba(255, 0, 0, 0.5); - p { - color: opacify($translucent-red, 0.8); - background-color: transparentize($translucent-red, 50%); - } - -is compiled to: - - p { - color: rgba(255, 0, 0, 0.9); - background-color: rgba(255, 0, 0, 0.25); } - -#### String Operations - -The `+` operation can be used to concatenate strings: - - p { - cursor: e + -resize; - } - -is compiled to: - - p { - cursor: e-resize; } - -Note that if a quoted string is added to an unquoted string -(that is, the quoted string is to the left of the `+`), -the result is a quoted string. -Likewise, if an unquoted string is added to a quoted string -(the unquoted string is to the left of the `+`), -the result is an unquoted string. -For example: - - p:before { - content: "Foo " + Bar; - font-family: sans- + "serif"; } - -is compiled to: - - p:before { - content: "Foo Bar"; - font-family: sans-serif; } - -By default, if two values are placed next to one another, -they are concatenated with a space: - - p { - margin: 3px + 4px auto; - } - -is compiled to: - - p { - margin: 7px auto; } - -Within a string of text, #{} style interpolation can be used to -place dynamic values within the string: - - p:before { - content: "I ate #{5 + 10} pies!"; } - -is compiled to: - - p:before { - content: "I ate 15 pies!"; } - -#### Boolean Operations - -SassScript supports `and`, `or`, and `not` operators -for boolean values. - -#### List Operations - -Lists don't support any special operations. -Instead, they're manipulated using the -{file:Sass/Script/Functions.html#list-functions list functions}. - -### Parentheses - -Parentheses can be used to affect the order of operations: - - p { - width: 1em + (2em * 3); - } - -is compiled to: - - p { - width: 7em; } - -### Functions - -SassScript defines some useful functions -that are called using the normal CSS function syntax: - - p { - color: hsl(0, 100%, 50%); - } - -is compiled to: - - p { - color: #ff0000; } - -#### Keyword Arguments - -Sass functions can also be called using explicit keyword arguments. -The above example can also be written as: - - p { - color: hsl($hue: 0, $saturation: 100%, $lightness: 50%); - } - -While this is less concise, it can make the stylesheet easier to read. -It also allows functions to present more flexible interfaces, -providing many arguments without becoming difficult to call. - -Named arguments can be passed in any order, and arguments with default values can be omitted. -Since the named arguments are variable names, underscores and dashes can be used interchangeably. - -See {Sass::Script::Functions} for a full listing of Sass functions and their argument names, -as well as instructions on defining your own in Ruby. - -### Interpolation: `#{}` {#interpolation_} - -You can also use SassScript variables in selectors -and property names using #{} interpolation syntax: - - $name: foo; - $attr: border; - p.#{$name} { #{$attr}-color: blue } - -is compiled to: - - p.foo { - border-color: blue; } - -It's also possible to use `#{}` to put SassScript into property values. -In most cases this isn't any better than using a variable, -but using `#{}` does mean that any operations near it -will be treated as plain CSS. -For example: - - p { - $font-size: 12px; - $line-height: 30px; - font: #{$font-size}/#{$line-height}; - } - -is compiled to: - - p { - font: 12px/30px; - } - -### Variable Defaults: `!default` - -You can assign to variables if they aren't already assigned -by adding the `!default` flag to the end of the value. -This means that if the variable has already been assigned to, -it won't be re-assigned, -but if it doesn't have a value yet, it will be given one. - -For example: - - $content: "First content"; - $content: "Second content?" !default; - $new_content: "First time reference" !default; - - #main { - content: $content; - new-content: $new_content; - } - -is compiled to: - - #main { - content: "First content"; - new-content: "First time reference"; } - -## `@`-Rules and Directives {#directives} - -Sass supports all CSS3 `@`-rules, -as well as some additional Sass-specific ones -known as "directives." -These have various effects in Sass, detailed below. -See also [control directives](#control-directives) -and [mixin directives](#mixins). - -### `@import` {#import} - -Sass extends the CSS `@import` rule -to allow it to import SCSS and Sass files. -All imported SCSS and Sass files will be merged together -into a single CSS output file. -In addition, any variables or [mixins](#mixins) -defined in imported files can be used in the main file. - -Sass looks for other Sass files in the current directory, -and the Sass file directory under Rack, Rails, or Merb. -Additional search directories may be specified -using the [`:load_paths`](#load_paths-option) option, -or the `--load-path` option on the command line. - -`@import` takes a filename to import. -By default, it looks for a Sass file to import directly, -but there are a few circumstances under which it will compile to a CSS `@import` rule: - -* If the file's extension is `.css`. -* If the filename begins with `http://`. -* If the filename is a `url()`. -* If the `@import` has any media queries. - -If none of the above conditions are met -and the extension is `.scss` or `.sass`, -then the named Sass or SCSS file will be imported. -If there is no extension, -Sass will try to find a file with that name and the `.scss` or `.sass` extension -and import it. - -For example, - - @import "foo.scss"; - -or - - @import "foo"; - -would both import the file `foo.scss`, -whereas - - @import "foo.css"; - @import "foo" screen; - @import "http://foo.com/bar"; - @import url(foo); - -would all compile to - - @import "foo.css"; - @import "foo" screen; - @import "http://foo.com/bar"; - @import url(foo); - -It's also possible to import multiple files in one `@import`. For example: - - @import "rounded-corners", "text-shadow"; - -would import both the `rounded-corners` and the `text-shadow` files. - -#### Partials {#partials} - -If you have a SCSS or Sass file that you want to import -but don't want to compile to a CSS file, -you can add an underscore to the beginning of the filename. -This will tell Sass not to compile it to a normal CSS file. -You can then import these files without using the underscore. - -For example, you might have `_colors.scss`. -Then no `_colors.css` file would be created, -and you can do - - @import "colors"; - -and `_colors.scss` would be imported. - -#### Nested `@import` {#nested-import} - -Although most of the time it's most useful to just have `@import`s -at the top level of the document, -it is possible to include them within CSS rules and `@media` rules. -Like a base-level `@import`, this includes the contents of the `@import`ed file. -However, the imported rules will be nested in the same place as the original `@import`. - -For example, if `example.scss` contains - - .example { - color: red; - } - -then - - #main { - @import "example"; - } - -would compile to - - #main .example { - color: red; - } - -Directives that are only allowed at the base level of a document, -like `@mixin` or `@charset`, are not allowed in files that are `@import`ed -in a nested context. - -It's not possible to nest `@import` within mixins or control directives. - -### `@media` {#media} - -`@media` directives in Sass behave just like they do in plain CSS, -with one extra capability: they can be nested in CSS rules. -If a `@media` directive appears within a CSS rule, -it will be bubbled up to the top level of the stylesheet, -putting all the selectors on the way inside the rule. -This makes it easy to add media-specific styles -without having to repeat selectors -or break the flow of the stylesheet. -For example: - - .sidebar { - width: 300px; - @media screen and (orientation: landscape) { - width: 500px; - } - } - -is compiled to: - - .sidebar { - width: 300px; - } - @media screen and (orientation: landscape) { - .sidebar { - width: 500px; - } - } - -`@media` queries can also be nested within one another. -The queries will then be combined using the `and` operator. -For example: - - @media screen { - .sidebar { - @media (orientation: landscape) { - width: 500px; - } - } - } - -is compiled to: - - @media screen and (orientation: landscape) { - .sidebar { - width: 500px; - } - } - -### `@extend` {#extend} - -There are often cases when designing a page -when one class should have all the styles of another class, -as well as its own specific styles. -The most common way of handling this is to use both the more general class -and the more specific class in the HTML. -For example, suppose we have a design for a normal error -and also for a serious error. We might write our markup like so: - -
    - Oh no! You've been hacked! -
    - -And our styles like so: - - .error { - border: 1px #f00; - background-color: #fdd; - } - .seriousError { - border-width: 3px; - } - -Unfortunately, this means that we have to always remember -to use `.error` with `.seriousError`. -This is a maintenance burden, leads to tricky bugs, -and can bring non-semantic style concerns into the markup. - -The `@extend` directive avoids these problems -by telling Sass that one selector should inherit the styles of another selector. -For example: - - .error { - border: 1px #f00; - background-color: #fdd; - } - .seriousError { - @extend .error; - border-width: 3px; - } - -This means that all styles defined for `.error` -are also applied to `.seriousError`, -in addition to the styles specific to `.seriousError`. -In effect, everything with class `.seriousError` also has class `.error`. - -Other rules that use `.error` will work for `.seriousError` as well. -For example, if we have special styles for errors caused by hackers: - - .error.intrusion { - background-image: url("/image/hacked.png"); - } - -Then `
    ` -will have the `hacked.png` background image as well. - -#### How it Works - -`@extend` works by inserting the extending selector (e.g. `.seriousError`) -anywhere in the stylesheet that the extended selector (.e.g `.error`) appears. -Thus the example above: - - .error { - border: 1px #f00; - background-color: #fdd; - } - .error.intrusion { - background-image: url("/image/hacked.png"); - } - .seriousError { - @extend .error; - border-width: 3px; - } - -is compiled to: - - .error, .seriousError { - border: 1px #f00; - background-color: #fdd; } - - .error.intrusion, .seriousError.intrusion { - background-image: url("/image/hacked.png"); } - - .seriousError { - border-width: 3px; } - -When merging selectors, `@extend` is smart enough -to avoid unnecessary duplication, -so something like `.seriousError.seriousError` gets translated to `.seriousError`. -In addition, it won't produce selectors that can't match anything, like `#main#footer`. - -#### Extending Complex Selectors - -Class selectors aren't the only things that can be extended. -It's possible to extend any selector involving only a single element, -such as `.special.cool`, `a:hover`, or `a.user[href^="http://"]`. -For example: - - .hoverlink {@extend a:hover} - -Just like with classes, this means that all styles defined for `a:hover` -are also applied to `.hoverlink`. -For example: - - .hoverlink {@extend a:hover} - a:hover {text-decoration: underline} - -is compiled to: - - a:hover, .hoverlink {text-decoration: underline} - -Just like with `.error.intrusion` above, -any rule that uses `a:hover` will also work for `.hoverlink`, -even if they have other selectors as well. -For example: - - .hoverlink {@extend a:hover} - .comment a.user:hover {font-weight: bold} - -is compiled to: - - .comment a.user:hover, .comment .hoverlink.user {font-weight: bold} - -#### Multiple Extends - -A single selector can extend more than one selector. -This means that it inherits the styles of all the extended selectors. -For example: - - .error { - border: 1px #f00; - background-color: #fdd; - } - .attention { - font-size: 3em; - background-color: #ff0; - } - .seriousError { - @extend .error; - @extend .attention; - border-width: 3px; - } - -is compiled to: - - .error, .seriousError { - border: 1px #f00; - background-color: #fdd; } - - .attention, .seriousError { - font-size: 3em; - background-color: #ff0; } - - .seriousError { - border-width: 3px; } - -In effect, everything with class `.seriousError` -also has class `.error` *and* class `.attention`. -Thus, the styles defined later in the document take precedence: -`.seriousError` has background color `#ff0` rather than `#fdd`, -since `.attention` is defined later than `.error`. - -#### Chaining Extends - -It's possible for one selector to extend another selector -that in turn extends a third. -For example: - - .error { - border: 1px #f00; - background-color: #fdd; - } - .seriousError { - @extend .error; - border-width: 3px; - } - .criticalError { - @extend .seriousError; - position: fixed; - top: 10%; - bottom: 10%; - left: 10%; - right: 10%; - } - -Now everything with class `.seriousError` also has class `.error`, -and everything with class `.criticalError` has class `.seriousError` -*and* class `.error`. -It's compiled to: - - .error, .seriousError, .criticalError { - border: 1px #f00; - background-color: #fdd; } - - .seriousError, .criticalError { - border-width: 3px; } - - .criticalError { - position: fixed; - top: 10%; - bottom: 10%; - left: 10%; - right: 10%; } - -#### Selector Sequences - -Selector sequences, such as `.foo .bar` or `.foo + .bar`, currently can't be extended. -However, it is possible for nested selectors themselves to use `@extend`. -For example: - - #fake-links .link {@extend a} - - a { - color: blue; - &:hover {text-decoration: underline} - } - -is compiled to - - a, #fake-links .link { - color: blue; } - a:hover, #fake-links .link:hover { - text-decoration: underline; } - -##### Merging Selector Sequences - -Sometimes a selector sequence extends another selector that appears in another sequence. -In this case, the two sequences need to be merged. -For example: - - #admin .tabbar a {font-weight: bold} - #demo .overview .fakelink {@extend a} - -While it would technically be possible -to generate all selectors that could possibly match either sequence, -this would make the stylesheet far too large. -The simple example above, for instance, would require ten selectors. -Instead, Sass generates only selectors that are likely to be useful. - -When the two sequences being merged have no selectors in common, -then two new selectors are generated: -one with the first sequence before the second, -and one with the second sequence before the first. -For example: - - #admin .tabbar a {font-weight: bold} - #demo .overview .fakelink {@extend a} - -is compiled to: - - #admin .tabbar a, - #admin .tabbar #demo .overview .fakelink, - #demo .overview #admin .tabbar .fakelink { - font-weight: bold; } - -If the two sequences do share some selectors, -then those selectors will be merged together -and only the differences (if any still exist) will alternate. -In this example, both sequences contain the id `#admin`, -so the resulting selectors will merge those two ids: - - #admin .tabbar a {font-weight: bold} - #admin .overview .fakelink {@extend a} - -This is compiled to: - - #admin .tabbar a, - #admin .tabbar .overview .fakelink, - #admin .overview .tabbar .fakelink { - font-weight: bold; } - -### `@debug` - -The `@debug` directive prints the value of a SassScript expression -to the standard error output stream. -It's useful for debugging Sass files -that have complicated SassScript going on. -For example: - - @debug 10em + 12em; - -outputs: - - Line 1 DEBUG: 22em - -### `@warn` - -The `@warn` directive prints the value of a SassScript expression -to the standard error output stream. -It's useful for libraries that need to warn users of deprecations -or recovering from minor mixin usage mistakes. -There are two major distinctions between `@warn` and `@debug`: - -1. You can turn warnings off with the `--quiet` command-line option - or the `:quiet` Sass option. -2. A stylesheet trace will be printed out along with the message - so that the user being warned can see where their styles caused the warning. - -Usage Example: - - @mixin adjust-location($x, $y) { - @if unitless($x) { - @warn "Assuming #{$x} to be in pixels"; - $x: 1px * $x; - } - @if unitless($y) { - @warn "Assuming #{$y} to be in pixels"; - $y: 1px * $y; - } - position: relative; left: $x; top: $y; - } - -## Control Directives - -SassScript supports basic control directives -for including styles only under some conditions -or including the same style several times with variations. - -**Note that control directives are an advanced feature, -and are not recommended in the course of day-to-day styling**. -They exist mainly for use in [mixins](#mixins), -particularly those that are part of libraries like [Compass](http://compass-style.org), -and so require substantial flexibility. - -### `@if` - -The `@if` directive takes a SassScript expression -and uses the styles nested beneath it if the expression returns -anything other than `false`: - - p { - @if 1 + 1 == 2 { border: 1px solid; } - @if 5 < 3 { border: 2px dotted; } - } - -is compiled to: - - p { - border: 1px solid; } - -The `@if` statement can be followed by several `@else if` statements -and one `@else` statement. -If the `@if` statement fails, -the `@else if` statements are tried in order -until one succeeds or the `@else` is reached. -For example: - - $type: monster; - p { - @if $type == ocean { - color: blue; - } @else if $type == matador { - color: red; - } @else if $type == monster { - color: green; - } @else { - color: black; - } - } - -is compiled to: - - p { - color: green; } - -### `@for` - -The `@for` directive has two forms: -`@for $var from to ` or -`@for $var from through `. -`$var` can be any variable name, like `$i`, -and `` and `` are SassScript expressions -that should return integers. - -The `@for` statement sets `$var` to each number -from `` to ``, -including `` if `through` is used. -Then it outputs the nested styles -using that value of `$var`. -For example: - - @for $i from 1 through 3 { - .item-#{$i} { width: 2em * $i; } - } - -is compiled to: - - .item-1 { - width: 2em; } - .item-2 { - width: 4em; } - .item-3 { - width: 6em; } - -### `@each` {#each-directive} - -The `@each` rule has the form `@each $var in `. -`$var` can be any variable name, like `$length` or `$name`, -and `` is a SassScript expression that returns a list. - -The `@each` rule sets `$var` to each item in the list, -then outputs the styles it contains using that value of `$var`. -For example: - - @each $animal in puma, sea-slug, egret, salamander { - .#{$animal}-icon { - background-image: url('/images/#{$animal}.png'); - } - } - -is compiled to: - - .puma-icon { - background-image: url('/images/puma.png'); } - .sea-slug-icon { - background-image: url('/images/sea-slug.png'); } - .egret-icon { - background-image: url('/images/egret.png'); } - .salamander-icon { - background-image: url('/images/salamander.png'); } - -### `@while` - -The `@while` directive takes a SassScript expression -and repeatedly outputs the nested styles -until the statement evaluates to `false`. -This can be used to achieve more complex looping -than the `@for` statement is capable of, -although this is rarely necessary. -For example: - - $i: 6; - @while $i > 0 { - .item-#{$i} { width: 2em * $i; } - $i: $i - 2; - } - -is compiled to: - - .item-6 { - width: 12em; } - - .item-4 { - width: 8em; } - - .item-2 { - width: 4em; } - -## Mixin Directives {#mixins} - -Mixins allow you to define styles -that can be re-used throughout the stylesheet -without needing to resort to non-semantic classes like `.float-left`. -Mixins can also contain full CSS rules, -and anything else allowed elsewhere in a Sass document. -They can even take [arguments](#mixin-arguments) -which allows you to produce a wide variety of styles -with very few mixins. - -### Defining a Mixin: `@mixin` {#defining_a_mixin} - -Mixins are defined with the `@mixin` directive. -It's followed by the name of the mixin -and optionally the [arguments](#mixin-arguments), -and a block containing the contents of the mixin. -For example, the `large-text` mixin is defined as follows: - - @mixin large-text { - font: { - family: Arial; - size: 20px; - weight: bold; - } - color: #ff0000; - } - -Mixins may also contain selectors, -possibly mixed with properties. -The selectors can even contain [parent references](#referencing_parent_selectors_). -For example: - - @mixin clearfix { - display: inline-block; - &:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; - } - * html & { height: 1px } - } - -### Including a Mixin: `@include` {#including_a_mixin} - -Mixins are included in the document -with the `@include` directive. -This takes the name of a mixin -and optionally [arguments to pass to it](#mixin-arguments), -and includes the styles defined by that mixin -into the current rule. -For example: - - .page-title { - @include large-text; - padding: 4px; - margin-top: 10px; - } - -is compiled to: - - .page-title { - font-family: Arial; - font-size: 20px; - font-weight: bold; - color: #ff0000; - padding: 4px; - margin-top: 10px; } - -Mixins may also be included outside of any rule -(that is, at the root of the document) -as long as they don't directly define any properties -or use any parent references. -For example: - - @mixin silly-links { - a { - color: blue; - background-color: red; - } - } - - @include silly-links; - -is compiled to: - - a { - color: blue; - background-color: red; } - -Mixin definitions can also include other mixins. -For example: - - @mixin compound { - @include highlighted-background; - @include header-text; - } - - @mixin highlighted-background { background-color: #fc0; } - @mixin header-text { font-size: 20px; } - -Mixins that only define descendent selectors, can be safely mixed -into the top most level of a document. - -### Arguments {#mixin-arguments} - -Mixins can take arguments SassScript values as arguments, -which are given when the mixin is included -and made available within the mixin as variables. - -When defining a mixin, -the arguments are written as variable names separated by commas, -all in parentheses after the name. -Then when including the mixin, -values can be passed in in the same manner. -For example: - - @mixin sexy-border($color, $width) { - border: { - color: $color; - width: $width; - style: dashed; - } - } - - p { @include sexy-border(blue, 1in); } - -is compiled to: - - p { - border-color: blue; - border-width: 1in; - border-style: dashed; } - -Mixins can also specify default values for their arguments -using the normal variable-setting syntax. -Then when the mixin is included, -if it doesn't pass in that argument, -the default value will be used instead. -For example: - - @mixin sexy-border($color, $width: 1in) { - border: { - color: $color; - width: $width; - style: dashed; - } - } - p { @include sexy-border(blue); } - h1 { @include sexy-border(blue, 2in); } - -is compiled to: - - p { - border-color: blue; - border-width: 1in; - border-style: dashed; } - - h1 { - border-color: blue; - border-width: 2in; - border-style: dashed; } - -#### Keyword Arguments - -Mixins can also be included using explicit keyword arguments. -For instance, we the above example could be written as: - - p { @include sexy-border($color: blue); } - h1 { @include sexy-border($color: blue, $width: 2in); } - -While this is less concise, it can make the stylesheet easier to read. -It also allows functions to present more flexible interfaces, -providing many arguments without becoming difficult to call. - -Named arguments can be passed in any order, and arguments with default values can be omitted. -Since the named arguments are variable names, underscores and dashes can be used interchangeably. - -## Function Directives {#functions} - -It is possible to define your own functions in sass and use them in any -value or script context. For example: - - $grid-width: 40px; - $gutter-width: 10px; - - @function grid-width($n) { - @return $n * $grid-width + ($n - 1) * $gutter-width; - } - - #sidebar { width: grid-width(5); } - -Becomes: - - #sidebar { - width: 240px; } - -As you can see functions can access any globally defined variables as well as -accept arguments just like a mixin. A function may have several statements -contained within it, and you must call `@return` to set the return value of -the function. - -As with mixins, you can call Sass-defined functions using keyword arguments. -In the above example we could have called the function like this: - - #sidebar { width: grid-width($n: 5); } - -It is recommended that you prefix your functions to avoid naming conflicts -and so that readers of your stylesheets know they are not part of Sass or CSS. For example, if you work for ACME Corp, you might have named the function above `-acme-grid-width`. - -## Output Style - -Although the default CSS style that Sass outputs is very nice -and reflects the structure of the document, -tastes and needs vary and so Sass supports several other styles. - -Sass allows you to choose between four different output styles -by setting the [`:style` option](#style-option) -or using the `--style` command-line flag. - -### `:nested` - -Nested style is the default Sass style, -because it reflects the structure of the CSS styles -and the HTML document they're styling. -Each property has its own line, -but the indentation isn't constant. -Each rule is indented based on how deeply it's nested. -For example: - - #main { - color: #fff; - background-color: #000; } - #main p { - width: 10em; } - - .huge { - font-size: 10em; - font-weight: bold; - text-decoration: underline; } - -Nested style is very useful when looking at large CSS files: -it allows you to easily grasp the structure of the file -without actually reading anything. - -### `:expanded` - -Expanded is a more typical human-made CSS style, -with each property and rule taking up one line. -Properties are indented within the rules, -but the rules aren't indented in any special way. -For example: - - #main { - color: #fff; - background-color: #000; - } - #main p { - width: 10em; - } - - .huge { - font-size: 10em; - font-weight: bold; - text-decoration: underline; - } - -### `:compact` - -Compact style takes up less space than Nested or Expanded. -It also draws the focus more to the selectors than to their properties. -Each CSS rule takes up only one line, -with every property defined on that line. -Nested rules are placed next to each other with no newline, -while separate groups of rules have newlines between them. -For example: - - #main { color: #fff; background-color: #000; } - #main p { width: 10em; } - - .huge { font-size: 10em; font-weight: bold; text-decoration: underline; } - -### `:compressed` - -Compressed style takes up the minimum amount of space possible, -having no whitespace except that necessary to separate selectors -and a newline at the end of the file. -It also includes some other minor compressions, -such as choosing the smallest representation for colors. -It's not meant to be human-readable. -For example: - - #main{color:#fff;background-color:#000}#main p{width:10em}.huge{font-size:10em;font-weight:bold;text-decoration:underline} - -## Extending Sass - -Sass provides a number of advanced customizations for users with unique requirements. -Using these features requires a strong understanding of Ruby. - -### Defining Custom Sass Functions - -Users can define their own Sass functions using the Ruby API. -For more information, see the [source documentation](Sass/Script/Functions.html#adding_custom_functions). - -### Cache Stores - -Sass caches parsed documents so that they can be reused without parsing them again -unless they have changed. By default, Sass will write these cache files to a location -on the filesystem indicated by [`:cache_location`](#cache_location-option). If you -cannot write to the filesystem or need to share cache across ruby processes or machines, -then you can define your own cache store and set the[`:cache_store` -option](#cache_store-option). For details on creating your own cache store, please -see the {Sass::CacheStores::Base source documentation}. - -### Custom Importers - -Sass importers are in charge of taking paths passed to `@import` and finding the -appropriate Sass code for those paths. By default, this code is loaded from -the {Sass::Importers::Filesystem filesystem}, but importers could be added to load -from a database, over HTTP, or use a different file naming scheme than what Sass expects. - -Each importer is in charge of a single load path (or whatever the corresponding notion -is for the backend). Importers can be placed in the {file:SASS_REFERENCE.md#load_paths-option -`:load_paths` array} alongside normal filesystem paths. - -When resolving an `@import`, Sass will go through the load paths looking for an importer -that successfully imports the path. Once one is found, the imported file is used. - -User-created importers must inherit from {Sass::Importers::Base}. diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md deleted file mode 100644 index 92ddbbe4cf..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md +++ /dev/null @@ -1,155 +0,0 @@ -# Intro to SCSS for Sass Users - -Sass 3 introduces a new syntax known as SCSS -which is fully compatible with the syntax of CSS3, -while still supporting the full power of Sass. -This means that every valid CSS3 stylesheet -is a valid SCSS file with the same meaning. -In addition, SCSS understands most CSS hacks -and vendor-specific syntax, such as [IE's old `filter` syntax](http://msdn.microsoft.com/en-us/library/ms533754%28VS.85%29.aspx). - -Since SCSS is a CSS extension, -everything that works in CSS works in SCSS. -This means that for a Sass user to understand it, -they need only understand how the Sass extensions work. -Most of these, such as variables, parent references, and directives work the same; -the only difference is that SCSS requires semicolons -and brackets instead of newlines and indentation. -For example, a simple rule in Sass: - - #sidebar - width: 30% - background-color: #faa - -could be converted to SCSS just by adding brackets and semicolons: - - #sidebar { - width: 30%; - background-color: #faa; - } - -In addition, SCSS is completely whitespace-insensitive. -That means the above could also be written as: - - #sidebar {width: 30%; background-color: #faa} - -There are some differences that are slightly more complicated. -These are detailed below. -Note, though, that SCSS uses all the -{file:SASS_CHANGELOG.md#3-0-0-syntax-changes syntax changes in Sass 3}, -so make sure you understand those before going forward. - -## Nested Selectors - -To nest selectors, simply define a new ruleset -inside an existing ruleset: - - #sidebar { - a { text-decoration: none; } - } - -Of course, white space is insignificant -and the last trailing semicolon is optional -so you can also do it like this: - - #sidebar { a { text-decoration: none } } - -## Nested Properties - -To nest properties, -simply create a new property set -after an existing property's colon: - - #footer { - border: { - width: 1px; - color: #ccc; - style: solid; - } - } - -This compiles to: - - #footer { - border-width: 1px; - border-color: #cccccc; - border-style: solid; } - -## Mixins - -A mixin is declared with the `@mixin` directive: - - @mixin rounded($amount) { - -moz-border-radius: $amount; - -webkit-border-radius: $amount; - border-radius: $amount; - } - -A mixin is used with the `@include` directive: - - .box { - border: 3px solid #777; - @include rounded(0.5em); - } - -This syntax is also available in the indented syntax, -although the old `=` and `+` syntax still works. - -This is rather verbose compared to the `=` and `+` characters used in Sass syntax. -This is because the SCSS format is designed for CSS compatibility rather than conciseness, -and creating new syntax when the CSS directive syntax already exists -adds new syntax needlessly and -could create incompatibilities with future versions of CSS. - -## Comments - -Like Sass, SCSS supports both comments that are preserved in the CSS output -and comments that aren't. -However, SCSS's comments are significantly more flexible. -It supports standard multiline CSS comments with `/* */`, -which are preserved where possible in the output. -These comments can have whatever formatting you like; -Sass will do its best to format them nicely. - -SCSS also uses `//` for comments that are thrown away, like Sass. -Unlike Sass, though, `//` comments in SCSS may appear anywhere -and last only until the end of the line. - -For example: - - /* This comment is - * several lines long. - * since it uses the CSS comment syntax, - * it will appear in the CSS output. */ - body { color: black; } - - // These comments are only one line long each. - // They won't appear in the CSS output, - // since they use the single-line comment syntax. - a { color: green; } - -is compiled to: - - /* This comment is - * several lines long. - * since it uses the CSS comment syntax, - * it will appear in the CSS output. */ - body { - color: black; } - - a { - color: green; } - -## `@import` - -The `@import` directive in SCSS functions just like that in Sass, -except that it takes a quoted string to import. -For example, this Sass: - - @import themes/dark - @import font.sass - -would be this SCSS: - - @import "themes/dark"; - @import "font.sass"; diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/ext/extconf.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/ext/extconf.rb deleted file mode 100644 index 0ecd6b27fc..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/ext/extconf.rb +++ /dev/null @@ -1,10 +0,0 @@ -root = File.expand_path("../..", __FILE__) -File.open(File.expand_path("lib/sass/root.rb", root), "w") do |f| - f << <<-RUBY -module Sass - ROOT_DIR = #{root.inspect} -end - RUBY -end - -File.open('Makefile', 'w') { |f| f.puts("install:\n\t$(exit 0)") } diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/extra/update_watch.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/extra/update_watch.rb deleted file mode 100644 index 73489a1785..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/extra/update_watch.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'rubygems' -require 'sinatra' -require 'json' -set :port, 3124 -set :environment, :production -enable :lock -Dir.chdir(File.dirname(__FILE__) + "/..") - -post "/" do - puts "Recieved payload!" - puts "Rev: #{`git name-rev HEAD`.strip}" - system %{rake handle_update --trace REF=#{JSON.parse(params["payload"])["ref"].inspect}} -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/init.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/init.rb deleted file mode 100644 index 5a3bceb4a4..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/init.rb +++ /dev/null @@ -1,18 +0,0 @@ -begin - require File.join(File.dirname(__FILE__), 'lib', 'sass') # From here -rescue LoadError - begin - require 'sass' # From gem - rescue LoadError => e - # gems:install may be run to install Haml with the skeleton plugin - # but not the gem itself installed. - # Don't die if this is the case. - raise e unless defined?(Rake) && - (Rake.application.top_level_tasks.include?('gems') || - Rake.application.top_level_tasks.include?('gems:install')) - end -end - -# Load Sass. -# Sass may be undefined if we're running gems:install. -require 'sass/plugin' if defined?(Sass) diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass.rb deleted file mode 100644 index 2a868769af..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass.rb +++ /dev/null @@ -1,72 +0,0 @@ -dir = File.dirname(__FILE__) -$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir) - -# This is necessary to set so that the Haml code that tries to load Sass -# knows that Sass is indeed loading, -# even if there's some crazy autoload stuff going on. -SASS_BEGUN_TO_LOAD = true unless defined?(SASS_BEGUN_TO_LOAD) - -require 'sass/version' - -# The module that contains everything Sass-related: -# -# * {Sass::Engine} is the class used to render Sass/SCSS within Ruby code. -# * {Sass::Plugin} is interfaces with web frameworks (Rails and Merb in particular). -# * {Sass::SyntaxError} is raised when Sass encounters an error. -# * {Sass::CSS} handles conversion of CSS to Sass. -# -# Also see the {file:SASS_REFERENCE.md full Sass reference}. -module Sass - # Compile a Sass or SCSS string to CSS. - # Defaults to SCSS. - # - # @param contents [String] The contents of the Sass file. - # @param options [{Symbol => Object}] An options hash; - # see {file:SASS_REFERENCE.md#sass_options the Sass options documentation} - # @raise [Sass::SyntaxError] if there's an error in the document - # @raise [Encoding::UndefinedConversionError] if the source encoding - # cannot be converted to UTF-8 - # @raise [ArgumentError] if the document uses an unknown encoding with `@charset` - def self.compile(contents, options = {}) - options[:syntax] ||= :scss - Engine.new(contents, options).to_css - end - - # Compile a file on disk to CSS. - # - # @param filename [String] The path to the Sass, SCSS, or CSS file on disk. - # @param options [{Symbol => Object}] An options hash; - # see {file:SASS_REFERENCE.md#sass_options the Sass options documentation} - # @raise [Sass::SyntaxError] if there's an error in the document - # @raise [Encoding::UndefinedConversionError] if the source encoding - # cannot be converted to UTF-8 - # @raise [ArgumentError] if the document uses an unknown encoding with `@charset` - # - # @overload compile_file(filename, options = {}) - # Return the compiled CSS rather than writing it to a file. - # - # @return [String] The compiled CSS. - # - # @overload compile_file(filename, css_filename, options = {}) - # Write the compiled CSS to a file. - # - # @param css_filename [String] The location to which to write the compiled CSS. - def self.compile_file(filename, *args) - options = args.last.is_a?(Hash) ? args.pop : {} - css_filename = args.shift - result = Sass::Engine.for_file(filename, options).render - if css_filename - options[:css_filename] ||= css_filename - open(css_filename,"w") {|css_file| css_file.write(result)} - nil - else - result - end - end -end - -require 'sass/util' - -require 'sass/engine' -require 'sass/plugin' if defined?(Merb::Plugins) -require 'sass/railtie' diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores.rb deleted file mode 100644 index 62259b3281..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'stringio' - -module Sass - # Sass cache stores are in charge of storing cached information, - # especially parse trees for Sass documents. - # - # User-created importers must inherit from {CacheStores::Base}. - module CacheStores - end -end - -require 'sass/cache_stores/base' -require 'sass/cache_stores/filesystem' -require 'sass/cache_stores/memory' -require 'sass/cache_stores/chain' diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/base.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/base.rb deleted file mode 100644 index 0d48f1455b..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/base.rb +++ /dev/null @@ -1,84 +0,0 @@ -module Sass - module CacheStores - # An abstract base class for backends for the Sass cache. - # Any key-value store can act as such a backend; - # it just needs to implement the - # \{#_store} and \{#_retrieve} methods. - # - # To use a cache store with Sass, - # use the {file:SASS_REFERENCE.md#cache_store-option `:cache_store` option}. - # - # @abstract - class Base - # Store cached contents for later retrieval - # Must be implemented by all CacheStore subclasses - # - # Note: cache contents contain binary data. - # - # @param key [String] The key to store the contents under - # @param version [String] The current sass version. - # Cached contents must not be retrieved across different versions of sass. - # @param sha [String] The sha of the sass source. - # Cached contents must not be retrieved if the sha has changed. - # @param contents [String] The contents to store. - def _store(key, version, sha, contents) - raise "#{self.class} must implement #_store." - end - - # Retrieved cached contents. - # Must be implemented by all subclasses. - # - # Note: if the key exists but the sha or version have changed, - # then the key may be deleted by the cache store, if it wants to do so. - # - # @param key [String] The key to retrieve - # @param version [String] The current sass version. - # Cached contents must not be retrieved across different versions of sass. - # @param sha [String] The sha of the sass source. - # Cached contents must not be retrieved if the sha has changed. - # @return [String] The contents that were previously stored. - # @return [NilClass] when the cache key is not found or the version or sha have changed. - def _retrieve(key, version, sha) - raise "#{self.class} must implement #_retrieve." - end - - # Store a {Sass::Tree::RootNode}. - # - # @param key [String] The key to store it under. - # @param sha [String] The checksum for the contents that are being stored. - # @param obj [Object] The object to cache. - def store(key, sha, root) - _store(key, Sass::VERSION, sha, Marshal.dump(root)) - end - - # Retrieve a {Sass::Tree::RootNode}. - # - # @param key [String] The key the root element was stored under. - # @param sha [String] The checksum of the root element's content. - # @return [Object] The cached object. - def retrieve(key, sha) - contents = _retrieve(key, Sass::VERSION, sha) - Marshal.load(contents) if contents - rescue EOFError, TypeError, ArgumentError => e - Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}" - end - - # Return the key for the sass file. - # - # The `(sass_dirname, sass_basename)` pair - # should uniquely identify the Sass document, - # but otherwise there are no restrictions on their content. - # - # @param sass_dirname [String] - # The fully-expanded location of the Sass file. - # This corresponds to the directory name on a filesystem. - # @param sass_basename [String] The name of the Sass file that is being referenced. - # This corresponds to the basename on a filesystem. - def key(sass_dirname, sass_basename) - dir = Digest::SHA1.hexdigest(sass_dirname) - filename = "#{sass_basename}c" - "#{dir}/#{filename}" - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/chain.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/chain.rb deleted file mode 100644 index 3d62635405..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/chain.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Sass - module CacheStores - # A meta-cache that chains multiple caches together. - # Specifically: - # - # * All `#store`s are passed to all caches. - # * `#retrieve`s are passed to each cache until one has a hit. - # * When one cache has a hit, the value is `#store`d in all earlier caches. - class Chain < Base - # Create a new cache chaining the given caches. - # - # @param caches [Array] The caches to chain. - def initialize(*caches) - @caches = caches - end - - # @see Base#store - def store(key, sha, obj) - @caches.each {|c| c.store(key, sha, obj)} - end - - # @see Base#retrieve - def retrieve(key, sha) - @caches.each_with_index do |c, i| - next unless obj = c.retrieve(key, sha) - @caches[0...i].each {|c| c.store(key, sha, obj)} - return obj - end - nil - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/filesystem.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/filesystem.rb deleted file mode 100644 index b0fae9058a..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/filesystem.rb +++ /dev/null @@ -1,58 +0,0 @@ -module Sass - module CacheStores - # A backend for the Sass cache using the filesystem. - class Filesystem < Base - # The directory where the cached files will be stored. - # - # @return [String] - attr_accessor :cache_location - - # @param cache_location [String] see \{#cache\_location} - def initialize(cache_location) - @cache_location = cache_location - end - - # @see Base#\_retrieve - def _retrieve(key, version, sha) - return unless File.readable?(path_to(key)) - contents = nil - File.open(path_to(key), "rb") do |f| - if f.readline("\n").strip == version && f.readline("\n").strip == sha - return f.read - end - end - File.unlink path_to(key) - nil - rescue EOFError, TypeError, ArgumentError => e - Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}" - end - - # @see Base#\_store - def _store(key, version, sha, contents) - # return unless File.writable?(File.dirname(@cache_location)) - # return if File.exists?(@cache_location) && !File.writable?(@cache_location) - compiled_filename = path_to(key) - # return if File.exists?(File.dirname(compiled_filename)) && !File.writable?(File.dirname(compiled_filename)) - # return if File.exists?(compiled_filename) && !File.writable?(compiled_filename) - FileUtils.mkdir_p(File.dirname(compiled_filename)) - File.open(compiled_filename, "wb") do |f| - f.puts(version) - f.puts(sha) - f.write(contents) - end - rescue Errno::EACCES - #pass - end - - private - - # Returns the path to a file for the given key. - # - # @param key [String] - # @return [String] The path to the cache file. - def path_to(key) - File.join(cache_location, key) - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/memory.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/memory.rb deleted file mode 100644 index 65dcf68c4f..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/memory.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Sass - module CacheStores - # A backend for the Sass cache using in-process memory. - class Memory < Base - # Since the {Memory} store is stored in the Sass tree's options hash, - # when the options get serialized as part of serializing the tree, - # you get crazy exponential growth in the size of the cached objects - # unless you don't dump the cache. - # - # @private - def _dump(depth) - "" - end - - # If we deserialize this class, just make a new empty one. - # - # @private - def self._load(repr) - Memory.new - end - - # Create a new, empty cache store. - def initialize - @contents = {} - end - - # @see Base#retrieve - def retrieve(key, sha) - if @contents.has_key?(key) - return unless @contents[key][:sha] == sha - obj = @contents[key][:obj] - obj.respond_to?(:deep_copy) ? obj.deep_copy : obj.dup - end - end - - # @see Base#store - def store(key, sha, obj) - @contents[key] = {:sha => sha, :obj => obj} - end - - # Destructively clear the cache. - def reset! - @contents = {} - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/null.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/null.rb deleted file mode 100644 index 3bf56cab07..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/cache_stores/null.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Sass - module CacheStores - # Doesn't store anything, but records what things it should have stored. - # This doesn't currently have any use except for testing and debugging. - # - # @private - class Null < Base - def initialize - @keys = {} - end - - def _retrieve(key, version, sha) - nil - end - - def _store(key, version, sha, contents) - @keys[key] = true - end - - def was_set?(key) - @keys[key] - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/callbacks.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/callbacks.rb deleted file mode 100644 index 70ea41def4..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/callbacks.rb +++ /dev/null @@ -1,66 +0,0 @@ -module Sass - # A lightweight infrastructure for defining and running callbacks. - # Callbacks are defined using \{#define\_callback\} at the class level, - # and called using `run_#{name}` at the instance level. - # - # Clients can add callbacks by calling the generated `on_#{name}` method, - # and passing in a block that's run when the callback is activated. - # - # @example Define a callback - # class Munger - # extend Sass::Callbacks - # define_callback :string_munged - # - # def munge(str) - # res = str.gsub(/[a-z]/, '\1\1') - # run_string_munged str, res - # res - # end - # end - # - # @example Use a callback - # m = Munger.new - # m.on_string_munged {|str, res| puts "#{str} was munged into #{res}!"} - # m.munge "bar" #=> bar was munged into bbaarr! - module Callbacks - # Automatically includes {InstanceMethods} - # when something extends this module. - # - # @param base [Module] - def self.extended(base) - base.send(:include, InstanceMethods) - end - protected - - module InstanceMethods - # Removes all callbacks registered against this object. - def clear_callbacks! - @_sass_callbacks = {} - end - end - - # Define a callback with the given name. - # This will define an `on_#{name}` method - # that registers a block, - # and a `run_#{name}` method that runs that block - # (optionall with some arguments). - # - # @param name [Symbol] The name of the callback - # @return [void] - def define_callback(name) - class_eval < "p\n color: blue" - # Sass::CSS.new("p { color: blue }").render(:scss) #=> "p {\n color: blue; }" - class CSS - # @param template [String] The CSS stylesheet. - # This stylesheet can be encoded using any encoding - # that can be converted to Unicode. - # If the stylesheet contains an `@charset` declaration, - # that overrides the Ruby encoding - # (see {file:SASS_REFERENCE.md#encodings the encoding documentation}) - # @option options :old [Boolean] (false) - # Whether or not to output old property syntax - # (`:color blue` as opposed to `color: blue`). - # This is only meaningful when generating Sass code, - # rather than SCSS. - def initialize(template, options = {}) - if template.is_a? IO - template = template.read - end - - @options = options.dup - # Backwards compatibility - @options[:old] = true if @options[:alternate] == false - @template = template - end - - # Converts the CSS template into Sass or SCSS code. - # - # @param fmt [Symbol] `:sass` or `:scss`, designating the format to return. - # @return [String] The resulting Sass or SCSS code - # @raise [Sass::SyntaxError] if there's an error parsing the CSS template - def render(fmt = :sass) - check_encoding! - build_tree.send("to_#{fmt}", @options).strip + "\n" - rescue Sass::SyntaxError => err - err.modify_backtrace(:filename => @options[:filename] || '(css)') - raise err - end - - # Returns the original encoding of the document, - # or `nil` under Ruby 1.8. - # - # @return [Encoding, nil] - # @raise [Encoding::UndefinedConversionError] if the source encoding - # cannot be converted to UTF-8 - # @raise [ArgumentError] if the document uses an unknown encoding with `@charset` - def source_encoding - check_encoding! - @original_encoding - end - - private - - def check_encoding! - return if @checked_encoding - @checked_encoding = true - @template, @original_encoding = Sass::Util.check_sass_encoding(@template) do |msg, line| - raise Sass::SyntaxError.new(msg, :line => line) - end - end - - # Parses the CSS template and applies various transformations - # - # @return [Tree::Node] The root node of the parsed tree - def build_tree - root = Sass::SCSS::CssParser.new(@template).parse - expand_commas root - parent_ref_rules root - remove_parent_refs root - flatten_rules root - fold_commas root - root - end - - # Transform - # - # foo, bar, baz - # color: blue - # - # into - # - # foo - # color: blue - # bar - # color: blue - # baz - # color: blue - # - # @param root [Tree::Node] The parent node - def expand_commas(root) - root.children.map! do |child| - unless child.is_a?(Tree::RuleNode) && child.rule.first.include?(',') - expand_commas(child) if child.is_a?(Tree::DirectiveNode) - next child - end - child.rule.first.split(',').map do |rule| - node = Tree::RuleNode.new([rule.strip]) - node.children = child.children - node - end - end - root.children.flatten! - end - - # Make rules use parent refs so that - # - # foo - # color: green - # foo.bar - # color: blue - # - # becomes - # - # foo - # color: green - # &.bar - # color: blue - # - # This has the side effect of nesting rules, - # so that - # - # foo - # color: green - # foo bar - # color: red - # foo baz - # color: blue - # - # becomes - # - # foo - # color: green - # & bar - # color: red - # & baz - # color: blue - # - # @param root [Tree::Node] The parent node - def parent_ref_rules(root) - current_rule = nil - root.children.map! do |child| - unless child.is_a?(Tree::RuleNode) - parent_ref_rules(child) if child.is_a?(Tree::DirectiveNode) - next child - end - - first, rest = child.rule.first.scan(/\A(&?(?: .|[^ ])[^.#: \[]*)([.#: \[].*)?\Z/m).first - - if current_rule.nil? || current_rule.rule.first != first - current_rule = Tree::RuleNode.new([first]) - end - - if rest - child.rule = ["&" + rest] - current_rule << child - else - current_rule.children += child.children - end - - current_rule - end - root.children.compact! - root.children.uniq! - - root.children.each { |v| parent_ref_rules(v) } - end - - # Remove useless parent refs so that - # - # foo - # & bar - # color: blue - # - # becomes - # - # foo - # bar - # color: blue - # - # @param root [Tree::Node] The parent node - def remove_parent_refs(root) - root.children.each do |child| - case child - when Tree::RuleNode - child.rule.first.gsub! /^& +/, '' - remove_parent_refs child - when Tree::DirectiveNode - remove_parent_refs child - end - end - end - - # Flatten rules so that - # - # foo - # bar - # color: red - # - # becomes - # - # foo bar - # color: red - # - # and - # - # foo - # &.bar - # color: blue - # - # becomes - # - # foo.bar - # color: blue - # - # @param root [Tree::Node] The parent node - def flatten_rules(root) - root.children.each do |child| - case child - when Tree::RuleNode - flatten_rule(child) - when Tree::DirectiveNode - flatten_rules(child) - end - end - end - - # Flattens a single rule - # - # @param rule [Tree::RuleNode] The candidate for flattening - # @see #flatten_rules - def flatten_rule(rule) - while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode) - child = rule.children.first - - if child.rule.first[0] == ?& - rule.rule = [child.rule.first.gsub(/^&/, rule.rule.first)] - else - rule.rule = ["#{rule.rule.first} #{child.rule.first}"] - end - - rule.children = child.children - end - - flatten_rules(rule) - end - - # Transform - # - # foo - # bar - # color: blue - # baz - # color: blue - # - # into - # - # foo - # bar, baz - # color: blue - # - # @param rule [Tree::RuleNode] The candidate for flattening - def fold_commas(root) - prev_rule = nil - root.children.map! do |child| - unless child.is_a?(Tree::RuleNode) - fold_commas(child) if child.is_a?(Tree::DirectiveNode) - next child - end - - if prev_rule && prev_rule.children == child.children - prev_rule.rule.first << ", #{child.rule.first}" - next nil - end - - fold_commas(child) - prev_rule = child - child - end - root.children.compact! - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/engine.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/engine.rb deleted file mode 100644 index a54143ab67..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/engine.rb +++ /dev/null @@ -1,862 +0,0 @@ -require 'strscan' -require 'set' -require 'digest/sha1' -require 'sass/cache_stores' -require 'sass/tree/node' -require 'sass/tree/root_node' -require 'sass/tree/rule_node' -require 'sass/tree/comment_node' -require 'sass/tree/prop_node' -require 'sass/tree/directive_node' -require 'sass/tree/media_node' -require 'sass/tree/variable_node' -require 'sass/tree/mixin_def_node' -require 'sass/tree/mixin_node' -require 'sass/tree/function_node' -require 'sass/tree/return_node' -require 'sass/tree/extend_node' -require 'sass/tree/if_node' -require 'sass/tree/while_node' -require 'sass/tree/for_node' -require 'sass/tree/each_node' -require 'sass/tree/debug_node' -require 'sass/tree/warn_node' -require 'sass/tree/import_node' -require 'sass/tree/charset_node' -require 'sass/tree/visitors/base' -require 'sass/tree/visitors/perform' -require 'sass/tree/visitors/cssize' -require 'sass/tree/visitors/convert' -require 'sass/tree/visitors/to_css' -require 'sass/tree/visitors/check_nesting' -require 'sass/selector' -require 'sass/environment' -require 'sass/script' -require 'sass/scss' -require 'sass/error' -require 'sass/importers' -require 'sass/shared' - -module Sass - - # A Sass mixin or function. - # - # `name`: `String` - # : The name of the mixin/function. - # - # `args`: `Array<(String, Script::Node)>` - # : The arguments for the mixin/function. - # Each element is a tuple containing the name of the argument - # and the parse tree for the default value of the argument. - # - # `environment`: {Sass::Environment} - # : The environment in which the mixin/function was defined. - # This is captured so that the mixin/function can have access - # to local variables defined in its scope. - # - # `tree`: `Array` - # : The parse tree for the mixin/function. - Callable = Struct.new(:name, :args, :environment, :tree) - - # This class handles the parsing and compilation of the Sass template. - # Example usage: - # - # template = File.load('stylesheets/sassy.sass') - # sass_engine = Sass::Engine.new(template) - # output = sass_engine.render - # puts output - class Engine - include Sass::Util - - # A line of Sass code. - # - # `text`: `String` - # : The text in the line, without any whitespace at the beginning or end. - # - # `tabs`: `Fixnum` - # : The level of indentation of the line. - # - # `index`: `Fixnum` - # : The line number in the original document. - # - # `offset`: `Fixnum` - # : The number of bytes in on the line that the text begins. - # This ends up being the number of bytes of leading whitespace. - # - # `filename`: `String` - # : The name of the file in which this line appeared. - # - # `children`: `Array` - # : The lines nested below this one. - class Line < Struct.new(:text, :tabs, :index, :offset, :filename, :children) - def comment? - text[0] == COMMENT_CHAR && (text[1] == SASS_COMMENT_CHAR || text[1] == CSS_COMMENT_CHAR) - end - end - - # The character that begins a CSS property. - PROPERTY_CHAR = ?: - - # The character that designates the beginning of a comment, - # either Sass or CSS. - COMMENT_CHAR = ?/ - - # The character that follows the general COMMENT_CHAR and designates a Sass comment, - # which is not output as a CSS comment. - SASS_COMMENT_CHAR = ?/ - - # The character that follows the general COMMENT_CHAR and designates a CSS comment, - # which is embedded in the CSS document. - CSS_COMMENT_CHAR = ?* - - # The character used to denote a compiler directive. - DIRECTIVE_CHAR = ?@ - - # Designates a non-parsed rule. - ESCAPE_CHAR = ?\\ - - # Designates block as mixin definition rather than CSS rules to output - MIXIN_DEFINITION_CHAR = ?= - - # Includes named mixin declared using MIXIN_DEFINITION_CHAR - MIXIN_INCLUDE_CHAR = ?+ - - # The regex that matches and extracts data from - # properties of the form `:name prop`. - PROPERTY_OLD = /^:([^\s=:"]+)\s*(?:\s+|$)(.*)/ - - # The default options for Sass::Engine. - # @api public - DEFAULT_OPTIONS = { - :style => :nested, - :load_paths => ['.'], - :cache => true, - :cache_location => './.sass-cache', - :syntax => :sass, - :filesystem_importer => Sass::Importers::Filesystem - }.freeze - - # Converts a Sass options hash into a standard form, filling in - # default values and resolving aliases. - # - # @param options [{Symbol => Object}] The options hash; - # see {file:SASS_REFERENCE.md#sass_options the Sass options documentation} - # @return [{Symbol => Object}] The normalized options hash. - # @private - def self.normalize_options(options) - options = DEFAULT_OPTIONS.merge(options.reject {|k, v| v.nil?}) - - # If the `:filename` option is passed in without an importer, - # assume it's using the default filesystem importer. - options[:importer] ||= options[:filesystem_importer].new(".") if options[:filename] - - # Tracks the original filename of the top-level Sass file - options[:original_filename] ||= options[:filename] - - options[:cache_store] ||= Sass::CacheStores::Chain.new( - Sass::CacheStores::Memory.new, Sass::CacheStores::Filesystem.new(options[:cache_location])) - # Support both, because the docs said one and the other actually worked - # for quite a long time. - options[:line_comments] ||= options[:line_numbers] - - options[:load_paths] = options[:load_paths].map do |p| - next p unless p.is_a?(String) || (defined?(Pathname) && p.is_a?(Pathname)) - options[:filesystem_importer].new(p.to_s) - end - - # Backwards compatibility - options[:property_syntax] ||= options[:attribute_syntax] - case options[:property_syntax] - when :alternate; options[:property_syntax] = :new - when :normal; options[:property_syntax] = :old - end - - options - end - - # Returns the {Sass::Engine} for the given file. - # This is preferable to Sass::Engine.new when reading from a file - # because it properly sets up the Engine's metadata, - # enables parse-tree caching, - # and infers the syntax from the filename. - # - # @param filename [String] The path to the Sass or SCSS file - # @param options [{Symbol => Object}] The options hash; - # See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}. - # @return [Sass::Engine] The Engine for the given Sass or SCSS file. - # @raise [Sass::SyntaxError] if there's an error in the document. - def self.for_file(filename, options) - had_syntax = options[:syntax] - - if had_syntax - # Use what was explicitly specificed - elsif filename =~ /\.scss$/ - options.merge!(:syntax => :scss) - elsif filename =~ /\.sass$/ - options.merge!(:syntax => :sass) - end - - Sass::Engine.new(File.read(filename), options.merge(:filename => filename)) - end - - # The options for the Sass engine. - # See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}. - # - # @return [{Symbol => Object}] - attr_reader :options - - # Creates a new Engine. Note that Engine should only be used directly - # when compiling in-memory Sass code. - # If you're compiling a single Sass file from the filesystem, - # use \{Sass::Engine.for\_file}. - # If you're compiling multiple files from the filesystem, - # use {Sass::Plugin. - # - # @param template [String] The Sass template. - # This template can be encoded using any encoding - # that can be converted to Unicode. - # If the template contains an `@charset` declaration, - # that overrides the Ruby encoding - # (see {file:SASS_REFERENCE.md#encodings the encoding documentation}) - # @param options [{Symbol => Object}] An options hash. - # See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}. - # @see {Sass::Engine.for_file} - # @see {Sass::Plugin} - def initialize(template, options={}) - @options = self.class.normalize_options(options) - @template = template - end - - # Render the template to CSS. - # - # @return [String] The CSS - # @raise [Sass::SyntaxError] if there's an error in the document - # @raise [Encoding::UndefinedConversionError] if the source encoding - # cannot be converted to UTF-8 - # @raise [ArgumentError] if the document uses an unknown encoding with `@charset` - def render - return _render unless @options[:quiet] - Sass::Util.silence_sass_warnings {_render} - end - alias_method :to_css, :render - - # Parses the document into its parse tree. Memoized. - # - # @return [Sass::Tree::Node] The root of the parse tree. - # @raise [Sass::SyntaxError] if there's an error in the document - def to_tree - @tree ||= @options[:quiet] ? - Sass::Util.silence_sass_warnings {_to_tree} : - _to_tree - end - - # Returns the original encoding of the document, - # or `nil` under Ruby 1.8. - # - # @return [Encoding, nil] - # @raise [Encoding::UndefinedConversionError] if the source encoding - # cannot be converted to UTF-8 - # @raise [ArgumentError] if the document uses an unknown encoding with `@charset` - def source_encoding - check_encoding! - @original_encoding - end - - # Gets a set of all the documents - # that are (transitive) dependencies of this document, - # not including the document itself. - # - # @return [[Sass::Engine]] The dependency documents. - def dependencies - _dependencies(Set.new, engines = Set.new) - engines - [self] - end - - # Helper for \{#dependencies}. - # - # @private - def _dependencies(seen, engines) - return if seen.include?(key = [@options[:filename], @options[:importer]]) - seen << key - engines << self - to_tree.grep(Tree::ImportNode) do |n| - next if n.css_import? - n.imported_file._dependencies(seen, engines) - end - end - - private - - def _render - rendered = _to_tree.render - return rendered if ruby1_8? - begin - # Try to convert the result to the original encoding, - # but if that doesn't work fall back on UTF-8 - rendered = rendered.encode(source_encoding) - rescue EncodingError - end - rendered.gsub(Regexp.new('\A@charset "(.*?)"'.encode(source_encoding)), - "@charset \"#{source_encoding.name}\"".encode(source_encoding)) - end - - def _to_tree - if (@options[:cache] || @options[:read_cache]) && - @options[:filename] && @options[:importer] - key = sassc_key - sha = Digest::SHA1.hexdigest(@template) - - if root = @options[:cache_store].retrieve(key, sha) - @options = root.options.merge(@options) - root.options = @options - return root - end - end - - check_encoding! - - if @options[:syntax] == :scss - root = Sass::SCSS::Parser.new(@template).parse - else - root = Tree::RootNode.new(@template) - append_children(root, tree(tabulate(@template)).first, true) - end - - root.options = @options - if @options[:cache] && key && sha - begin - old_options = root.options - root.options = {:importer => root.options[:importer]} - @options[:cache_store].store(key, sha, root) - ensure - root.options = old_options - end - end - root - rescue SyntaxError => e - e.modify_backtrace(:filename => @options[:filename], :line => @line) - e.sass_template = @template - raise e - end - - def sassc_key - @options[:cache_store].key(*@options[:importer].key(@options[:filename], @options)) - end - - def check_encoding! - return if @checked_encoding - @checked_encoding = true - @template, @original_encoding = check_sass_encoding(@template) do |msg, line| - raise Sass::SyntaxError.new(msg, :line => line) - end - end - - def tabulate(string) - tab_str = nil - comment_tab_str = nil - first = true - lines = [] - string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^[^\n]*?$/).each_with_index do |line, index| - index += (@options[:line] || 1) - if line.strip.empty? - lines.last.text << "\n" if lines.last && lines.last.comment? - next - end - - line_tab_str = line[/^\s*/] - unless line_tab_str.empty? - if tab_str.nil? - comment_tab_str ||= line_tab_str - next if try_comment(line, lines.last, "", comment_tab_str, index) - comment_tab_str = nil - end - - tab_str ||= line_tab_str - - raise SyntaxError.new("Indenting at the beginning of the document is illegal.", - :line => index) if first - - raise SyntaxError.new("Indentation can't use both tabs and spaces.", - :line => index) if tab_str.include?(?\s) && tab_str.include?(?\t) - end - first &&= !tab_str.nil? - if tab_str.nil? - lines << Line.new(line.strip, 0, index, 0, @options[:filename], []) - next - end - - comment_tab_str ||= line_tab_str - if try_comment(line, lines.last, tab_str * lines.last.tabs, comment_tab_str, index) - next - else - comment_tab_str = nil - end - - line_tabs = line_tab_str.scan(tab_str).size - if tab_str * line_tabs != line_tab_str - message = < index) - end - - lines << Line.new(line.strip, line_tabs, index, tab_str.size, @options[:filename], []) - end - lines - end - - def try_comment(line, last, tab_str, comment_tab_str, index) - return unless last && last.comment? - # Nested comment stuff must be at least one whitespace char deeper - # than the normal indentation - return unless line =~ /^#{tab_str}\s/ - unless line =~ /^(?:#{comment_tab_str})(.*)$/ - raise SyntaxError.new(< index) -Inconsistent indentation: -previous line was indented by #{Sass::Shared.human_indentation comment_tab_str}, -but this line was indented by #{Sass::Shared.human_indentation line[/^\s*/]}. -MSG - end - - last.text << "\n" << $1 - true - end - - def tree(arr, i = 0) - return [], i if arr[i].nil? - - base = arr[i].tabs - nodes = [] - while (line = arr[i]) && line.tabs >= base - if line.tabs > base - raise SyntaxError.new("The line was indented #{line.tabs - base} levels deeper than the previous line.", - :line => line.index) if line.tabs > base + 1 - - nodes.last.children, i = tree(arr, i) - else - nodes << line - i += 1 - end - end - return nodes, i - end - - def build_tree(parent, line, root = false) - @line = line.index - node_or_nodes = parse_line(parent, line, root) - - Array(node_or_nodes).each do |node| - # Node is a symbol if it's non-outputting, like a variable assignment - next unless node.is_a? Tree::Node - - node.line = line.index - node.filename = line.filename - - append_children(node, line.children, false) - end - - node_or_nodes - end - - def append_children(parent, children, root) - continued_rule = nil - continued_comment = nil - children.each do |line| - child = build_tree(parent, line, root) - - if child.is_a?(Tree::RuleNode) - if child.continued? && child.children.empty? - if continued_rule - continued_rule.add_rules child - else - continued_rule = child - end - next - elsif continued_rule - continued_rule.add_rules child - continued_rule.children = child.children - continued_rule, child = nil, continued_rule - end - elsif continued_rule - continued_rule = nil - end - - if child.is_a?(Tree::CommentNode) && child.silent - if continued_comment && - child.line == continued_comment.line + - continued_comment.value.count("\n") + 1 - continued_comment.value << "\n" << child.value - next - end - - continued_comment = child - end - - check_for_no_children(child) - validate_and_append_child(parent, child, line, root) - end - - parent - end - - def validate_and_append_child(parent, child, line, root) - case child - when Array - child.each {|c| validate_and_append_child(parent, c, line, root)} - when Tree::Node - parent << child - end - end - - def check_for_no_children(node) - return unless node.is_a?(Tree::RuleNode) && node.children.empty? - Sass::Util.sass_warn(< @line) if name.nil? || value.nil? - parse_property(name, parse_interp(name), value, :old, line) - end - when ?$ - parse_variable(line) - when COMMENT_CHAR - parse_comment(line.text) - when DIRECTIVE_CHAR - parse_directive(parent, line, root) - when ESCAPE_CHAR - Tree::RuleNode.new(parse_interp(line.text[1..-1])) - when MIXIN_DEFINITION_CHAR - parse_mixin_definition(line) - when MIXIN_INCLUDE_CHAR - if line.text[1].nil? || line.text[1] == ?\s - Tree::RuleNode.new(parse_interp(line.text)) - else - parse_mixin_include(line, root) - end - else - parse_property_or_rule(line) - end - end - - def parse_property_or_rule(line) - scanner = StringScanner.new(line.text) - hack_char = scanner.scan(/[:\*\.]|\#(?!\{)/) - parser = Sass::SCSS::SassParser.new(scanner, @line) - - unless res = parser.parse_interp_ident - return Tree::RuleNode.new(parse_interp(line.text)) - end - res.unshift(hack_char) if hack_char - if comment = scanner.scan(Sass::SCSS::RX::COMMENT) - res << comment - end - - name = line.text[0...scanner.pos] - if scanner.scan(/\s*:(?:\s|$)/) - parse_property(name, res, scanner.rest, :new, line) - else - res.pop if comment - Tree::RuleNode.new(res + parse_interp(scanner.rest)) - end - end - - def parse_property(name, parsed_name, value, prop, line) - if value.strip.empty? - expr = Sass::Script::String.new("") - else - important = false - if value =~ Sass::SCSS::RX::IMPORTANT - important = true - value = value.gsub(Sass::SCSS::RX::IMPORTANT,"") - end - expr = parse_script(value, :offset => line.offset + line.text.index(value)) - - end - Tree::PropNode.new(parse_interp(name), expr, important, prop) - end - - def parse_variable(line) - name, value, default = line.text.scan(Script::MATCH)[0] - raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath variable declarations.", - :line => @line + 1) unless line.children.empty? - raise SyntaxError.new("Invalid variable: \"#{line.text}\".", - :line => @line) unless name && value - - expr = parse_script(value, :offset => line.offset + line.text.index(value)) - - Tree::VariableNode.new(name, expr, default) - end - - def parse_comment(line) - if line[1] == CSS_COMMENT_CHAR || line[1] == SASS_COMMENT_CHAR - silent = line[1] == SASS_COMMENT_CHAR - Tree::CommentNode.new( - format_comment_text(line[2..-1], silent), - silent) - else - Tree::RuleNode.new(parse_interp(line)) - end - end - - def parse_directive(parent, line, root) - directive, whitespace, value = line.text[1..-1].split(/(\s+)/, 2) - offset = directive.size + whitespace.size + 1 if whitespace - - # If value begins with url( or ", - # it's a CSS @import rule and we don't want to touch it. - if directive == "import" - parse_import(line, value) - elsif directive == "mixin" - parse_mixin_definition(line) - elsif directive == "include" - parse_mixin_include(line, root) - elsif directive == "function" - parse_function(line, root) - elsif directive == "for" - parse_for(line, root, value) - elsif directive == "each" - parse_each(line, root, value) - elsif directive == "else" - parse_else(parent, line, value) - elsif directive == "while" - raise SyntaxError.new("Invalid while directive '@while': expected expression.") unless value - Tree::WhileNode.new(parse_script(value, :offset => offset)) - elsif directive == "if" - raise SyntaxError.new("Invalid if directive '@if': expected expression.") unless value - Tree::IfNode.new(parse_script(value, :offset => offset)) - elsif directive == "debug" - raise SyntaxError.new("Invalid debug directive '@debug': expected expression.") unless value - raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath debug directives.", - :line => @line + 1) unless line.children.empty? - offset = line.offset + line.text.index(value).to_i - Tree::DebugNode.new(parse_script(value, :offset => offset)) - elsif directive == "extend" - raise SyntaxError.new("Invalid extend directive '@extend': expected expression.") unless value - raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath extend directives.", - :line => @line + 1) unless line.children.empty? - offset = line.offset + line.text.index(value).to_i - Tree::ExtendNode.new(parse_interp(value, offset)) - elsif directive == "warn" - raise SyntaxError.new("Invalid warn directive '@warn': expected expression.") unless value - raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath warn directives.", - :line => @line + 1) unless line.children.empty? - offset = line.offset + line.text.index(value).to_i - Tree::WarnNode.new(parse_script(value, :offset => offset)) - elsif directive == "return" - raise SyntaxError.new("Invalid @return: expected expression.") unless value - raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath return directives.", - :line => @line + 1) unless line.children.empty? - offset = line.offset + line.text.index(value).to_i - Tree::ReturnNode.new(parse_script(value, :offset => offset)) - elsif directive == "charset" - name = value && value[/\A(["'])(.*)\1\Z/, 2] #" - raise SyntaxError.new("Invalid charset directive '@charset': expected string.") unless name - raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath charset directives.", - :line => @line + 1) unless line.children.empty? - Tree::CharsetNode.new(name) - elsif directive == "media" - Tree::MediaNode.new(value) - else - Tree::DirectiveNode.new(line.text) - end - end - - def parse_for(line, root, text) - var, from_expr, to_name, to_expr = text.scan(/^([^\s]+)\s+from\s+(.+)\s+(to|through)\s+(.+)$/).first - - if var.nil? # scan failed, try to figure out why for error message - if text !~ /^[^\s]+/ - expected = "variable name" - elsif text !~ /^[^\s]+\s+from\s+.+/ - expected = "'from '" - else - expected = "'to ' or 'through '" - end - raise SyntaxError.new("Invalid for directive '@for #{text}': expected #{expected}.") - end - raise SyntaxError.new("Invalid variable \"#{var}\".") unless var =~ Script::VALIDATE - - var = var[1..-1] - parsed_from = parse_script(from_expr, :offset => line.offset + line.text.index(from_expr)) - parsed_to = parse_script(to_expr, :offset => line.offset + line.text.index(to_expr)) - Tree::ForNode.new(var, parsed_from, parsed_to, to_name == 'to') - end - - def parse_each(line, root, text) - var, list_expr = text.scan(/^([^\s]+)\s+in\s+(.+)$/).first - - if var.nil? # scan failed, try to figure out why for error message - if text !~ /^[^\s]+/ - expected = "variable name" - elsif text !~ /^[^\s]+\s+from\s+.+/ - expected = "'in '" - end - raise SyntaxError.new("Invalid for directive '@each #{text}': expected #{expected}.") - end - raise SyntaxError.new("Invalid variable \"#{var}\".") unless var =~ Script::VALIDATE - - var = var[1..-1] - parsed_list = parse_script(list_expr, :offset => line.offset + line.text.index(list_expr)) - Tree::EachNode.new(var, parsed_list) - end - - def parse_else(parent, line, text) - previous = parent.children.last - raise SyntaxError.new("@else must come after @if.") unless previous.is_a?(Tree::IfNode) - - if text - if text !~ /^if\s+(.+)/ - raise SyntaxError.new("Invalid else directive '@else #{text}': expected 'if '.") - end - expr = parse_script($1, :offset => line.offset + line.text.index($1)) - end - - node = Tree::IfNode.new(expr) - append_children(node, line.children, false) - previous.add_else node - nil - end - - def parse_import(line, value) - raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath import directives.", - :line => @line + 1) unless line.children.empty? - - scanner = StringScanner.new(value) - values = [] - - loop do - unless node = parse_import_arg(scanner) - raise SyntaxError.new("Invalid @import: expected file to import, was #{scanner.rest.inspect}", - :line => @line) - end - values << node - break unless scanner.scan(/,\s*/) - end - - return values - end - - def parse_import_arg(scanner) - return if scanner.eos? - unless (str = scanner.scan(Sass::SCSS::RX::STRING)) || - (uri = scanner.scan(Sass::SCSS::RX::URI)) - return Tree::ImportNode.new(scanner.scan(/[^,]+/)) - end - - val = scanner[1] || scanner[2] - scanner.scan(/\s*/) - if media = scanner.scan(/[^,].*/) - Tree::DirectiveNode.new("@import #{str || uri} #{media}") - elsif uri - Tree::DirectiveNode.new("@import #{uri}") - elsif val =~ /^http:\/\// - Tree::DirectiveNode.new("@import url(#{val})") - else - Tree::ImportNode.new(val) - end - end - - MIXIN_DEF_RE = /^(?:=|@mixin)\s*(#{Sass::SCSS::RX::IDENT})(.*)$/ - def parse_mixin_definition(line) - name, arg_string = line.text.scan(MIXIN_DEF_RE).first - raise SyntaxError.new("Invalid mixin \"#{line.text[1..-1]}\".") if name.nil? - - offset = line.offset + line.text.size - arg_string.size - args = Script::Parser.new(arg_string.strip, @line, offset, @options). - parse_mixin_definition_arglist - Tree::MixinDefNode.new(name, args) - end - - MIXIN_INCLUDE_RE = /^(?:\+|@include)\s*(#{Sass::SCSS::RX::IDENT})(.*)$/ - def parse_mixin_include(line, root) - name, arg_string = line.text.scan(MIXIN_INCLUDE_RE).first - raise SyntaxError.new("Invalid mixin include \"#{line.text}\".") if name.nil? - - offset = line.offset + line.text.size - arg_string.size - args, keywords = Script::Parser.new(arg_string.strip, @line, offset, @options). - parse_mixin_include_arglist - raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath mixin directives.", - :line => @line + 1) unless line.children.empty? - Tree::MixinNode.new(name, args, keywords) - end - - FUNCTION_RE = /^@function\s*(#{Sass::SCSS::RX::IDENT})(.*)$/ - def parse_function(line, root) - name, arg_string = line.text.scan(FUNCTION_RE).first - raise SyntaxError.new("Invalid function definition \"#{line.text}\".") if name.nil? - - offset = line.offset + line.text.size - arg_string.size - args = Script::Parser.new(arg_string.strip, @line, offset, @options). - parse_function_definition_arglist - Tree::FunctionNode.new(name, args) - end - - def parse_script(script, options = {}) - line = options[:line] || @line - offset = options[:offset] || 0 - Script.parse(script, line, offset, @options) - end - - def format_comment_text(text, silent) - content = text.split("\n") - - if content.first && content.first.strip.empty? - removed_first = true - content.shift - end - - return silent ? "//" : "/* */" if content.empty? - content.last.gsub!(%r{ ?\*/ *$}, '') - content.map! {|l| l.gsub!(/^\*( ?)/, '\1') || (l.empty? ? "" : " ") + l} - content.first.gsub!(/^ /, '') unless removed_first - if silent - "//" + content.join("\n//") - else - # The #gsub fixes the case of a trailing */ - "/*" + content.join("\n *").gsub(/ \*\Z/, '') + " */" - end - end - - def parse_interp(text, offset = 0) - self.class.parse_interp(text, @line, offset, :filename => @filename) - end - - # It's important that this have strings (at least) - # at the beginning, the end, and between each Script::Node. - # - # @private - def self.parse_interp(text, line, offset, options) - res = [] - rest = Sass::Shared.handle_interpolation text do |scan| - escapes = scan[2].size - res << scan.matched[0...-2 - escapes] - if escapes % 2 == 1 - res << "\\" * (escapes - 1) << '#{' - else - res << "\\" * [0, escapes - 1].max - res << Script::Parser.new( - scan, line, offset + scan.pos - scan.matched_size, options). - parse_interpolated - end - end - res << rest - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/environment.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/environment.rb deleted file mode 100644 index b57799fc64..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/environment.rb +++ /dev/null @@ -1,155 +0,0 @@ -require 'set' - -module Sass - # The lexical environment for SassScript. - # This keeps track of variable, mixin, and function definitions. - # - # A new environment is created for each level of Sass nesting. - # This allows variables to be lexically scoped. - # The new environment refers to the environment in the upper scope, - # so it has access to variables defined in enclosing scopes, - # but new variables are defined locally. - # - # Environment also keeps track of the {Engine} options - # so that they can be made available to {Sass::Script::Functions}. - class Environment - # The enclosing environment, - # or nil if this is the global environment. - # - # @return [Environment] - attr_reader :parent - attr_writer :options - - # @param parent [Environment] See \{#parent} - def initialize(parent = nil) - @parent = parent - unless parent - @stack = [] - @mixins_in_use = Set.new - set_var("important", Script::String.new("!important")) - end - end - - # The options hash. - # See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}. - # - # @return [{Symbol => Object}] - def options - @options || parent_options || {} - end - - # Push a new stack frame onto the mixin/include stack. - # - # @param frame_info [{Symbol => Object}] - # Frame information has the following keys: - # - # `:filename` - # : The name of the file in which the lexical scope changed. - # - # `:mixin` - # : The name of the mixin in which the lexical scope changed, - # or `nil` if it wasn't within in a mixin. - # - # `:line` - # : The line of the file on which the lexical scope changed. Never nil. - def push_frame(frame_info) - top_of_stack = stack.last - if top_of_stack && top_of_stack.delete(:prepared) - top_of_stack.merge!(frame_info) - else - stack.push(top_of_stack = frame_info) - end - mixins_in_use << top_of_stack[:mixin] if top_of_stack[:mixin] && !top_of_stack[:prepared] - end - - # Like \{#push\_frame}, but next time a stack frame is pushed, - # it will be merged with this frame. - # - # @param frame_info [{Symbol => Object}] Same as for \{#push\_frame}. - def prepare_frame(frame_info) - push_frame(frame_info.merge(:prepared => true)) - end - - # Pop a stack frame from the mixin/include stack. - def pop_frame - stack.pop if stack.last && stack.last[:prepared] - popped = stack.pop - mixins_in_use.delete(popped[:mixin]) if popped && popped[:mixin] - end - - # A list of stack frames in the mixin/include stack. - # The last element in the list is the most deeply-nested frame. - # - # @return [Array<{Symbol => Object}>] The stack frames, - # of the form passed to \{#push\_frame}. - def stack - @stack ||= @parent.stack - end - - # A set of names of mixins currently present in the stack. - # - # @return [Set] The mixin names. - def mixins_in_use - @mixins_in_use ||= @parent.mixins_in_use - end - - private - - def parent_options - @parent_options ||= @parent && @parent.options - end - - class << self - private - UNDERSCORE, DASH = '_', '-' - - # Note: when updating this, - # update sass/yard/inherited_hash.rb as well. - def inherited_hash(name) - class_eval < Object>}] - attr_accessor :sass_backtrace - - # The text of the template where this error was raised. - # - # @return [String] - attr_accessor :sass_template - - # @param msg [String] The error message - # @param attrs [{Symbol => Object}] The information in the backtrace entry. - # See \{#sass\_backtrace} - def initialize(msg, attrs = {}) - @message = msg - @sass_backtrace = [] - add_backtrace(attrs) - end - - # The name of the file in which the exception was raised. - # This could be `nil` if no filename is available. - # - # @return [String, nil] - def sass_filename - sass_backtrace.first[:filename] - end - - # The name of the mixin in which the error occurred. - # This could be `nil` if the error occurred outside a mixin. - # - # @return [Fixnum] - def sass_mixin - sass_backtrace.first[:mixin] - end - - # The line of the Sass template on which the error occurred. - # - # @return [Fixnum] - def sass_line - sass_backtrace.first[:line] - end - - # Adds an entry to the exception's Sass backtrace. - # - # @param attrs [{Symbol => Object}] The information in the backtrace entry. - # See \{#sass\_backtrace} - def add_backtrace(attrs) - sass_backtrace << attrs.reject {|k, v| v.nil?} - end - - # Modify the top Sass backtrace entries - # (that is, the most deeply nested ones) - # to have the given attributes. - # - # Specifically, this goes through the backtrace entries - # from most deeply nested to least, - # setting the given attributes for each entry. - # If an entry already has one of the given attributes set, - # the pre-existing attribute takes precedence - # and is not used for less deeply-nested entries - # (even if they don't have that attribute set). - # - # @param attrs [{Symbol => Object}] The information to add to the backtrace entry. - # See \{#sass\_backtrace} - def modify_backtrace(attrs) - attrs = attrs.reject {|k, v| v.nil?} - # Move backwards through the backtrace - (0...sass_backtrace.size).to_a.reverse.each do |i| - entry = sass_backtrace[i] - sass_backtrace[i] = attrs.merge(entry) - attrs.reject! {|k, v| entry.include?(k)} - break if attrs.empty? - end - end - - # @return [String] The error message - def to_s - @message - end - - # Returns the standard exception backtrace, - # including the Sass backtrace. - # - # @return [Array] - def backtrace - return nil if super.nil? - return super if sass_backtrace.all? {|h| h.empty?} - sass_backtrace.map do |h| - "#{h[:filename] || "(sass)"}:#{h[:line]}" + - (h[:mixin] ? ":in `#{h[:mixin]}'" : "") - end + super - end - - # Returns a string representation of the Sass backtrace. - # - # @param default_filename [String] The filename to use for unknown files - # @see #sass_backtrace - # @return [String] - def sass_backtrace_str(default_filename = "an unknown file") - lines = self.message.split("\n") - msg = lines[0] + lines[1..-1]. - map {|l| "\n" + (" " * "Syntax error: ".size) + l}.join - "Syntax error: #{msg}" + - Sass::Util.enum_with_index(sass_backtrace).map do |entry, i| - "\n #{i == 0 ? "on" : "from"} line #{entry[:line]}" + - " of #{entry[:filename] || default_filename}" + - (entry[:mixin] ? ", in `#{entry[:mixin]}'" : "") - end.join - end - - class << self - # Returns an error report for an exception in CSS format. - # - # @param e [Exception] - # @param options [{Symbol => Object}] The options passed to {Sass::Engine#initialize} - # @return [String] The error report - # @raise [Exception] `e`, if the - # {file:SASS_REFERENCE.md#full_exception-option `:full_exception`} option - # is set to false. - def exception_to_css(e, options) - raise e unless options[:full_exception] - - header = header_string(e, options) - - <] The command-line arguments - def initialize(args) - @args = args - @options = {} - end - - # Parses the command-line arguments and runs the executable. - # Calls `Kernel#exit` at the end, so it never returns. - # - # @see #parse - def parse! - begin - parse - rescue Exception => e - raise e if @options[:trace] || e.is_a?(SystemExit) - - $stderr.print "#{e.class}: " unless e.class == RuntimeError - $stderr.puts "#{e.message}" - $stderr.puts " Use --trace for backtrace." - exit 1 - end - exit 0 - end - - # Parses the command-line arguments and runs the executable. - # This does not handle exceptions or exit the program. - # - # @see #parse! - def parse - @opts = OptionParser.new(&method(:set_opts)) - @opts.parse!(@args) - - process_result - - @options - end - - # @return [String] A description of the executable - def to_s - @opts.to_s - end - - protected - - # Finds the line of the source template - # on which an exception was raised. - # - # @param exception [Exception] The exception - # @return [String] The line number - def get_line(exception) - # SyntaxErrors have weird line reporting - # when there's trailing whitespace - return (exception.message.scan(/:(\d+)/).first || ["??"]).first if exception.is_a?(::SyntaxError) - (exception.backtrace[0].scan(/:(\d+)/).first || ["??"]).first - end - - # Tells optparse how to parse the arguments - # available for all executables. - # - # This is meant to be overridden by subclasses - # so they can add their own options. - # - # @param opts [OptionParser] - def set_opts(opts) - opts.on('-s', '--stdin', :NONE, 'Read input from standard input instead of an input file') do - @options[:input] = $stdin - end - - opts.on('--trace', :NONE, 'Show a full traceback on error') do - @options[:trace] = true - end - - opts.on('--unix-newlines', 'Use Unix-style newlines in written files.') do - @options[:unix_newlines] = true if ::Sass::Util.windows? - end - - opts.on_tail("-?", "-h", "--help", "Show this message") do - puts opts - exit - end - - opts.on_tail("-v", "--version", "Print version") do - puts("Sass #{::Sass.version[:string]}") - exit - end - end - - # Processes the options set by the command-line arguments. - # In particular, sets `@options[:input]` and `@options[:output]` - # to appropriate IO streams. - # - # This is meant to be overridden by subclasses - # so they can run their respective programs. - def process_result - input, output = @options[:input], @options[:output] - args = @args.dup - input ||= - begin - filename = args.shift - @options[:filename] = filename - open_file(filename) || $stdin - end - output ||= open_file(args.shift, 'w') || $stdout - - @options[:input], @options[:output] = input, output - end - - COLORS = { :red => 31, :green => 32, :yellow => 33 } - - # Prints a status message about performing the given action, - # colored using the given color (via terminal escapes) if possible. - # - # @param name [#to_s] A short name for the action being performed. - # Shouldn't be longer than 11 characters. - # @param color [Symbol] The name of the color to use for this action. - # Can be `:red`, `:green`, or `:yellow`. - def puts_action(name, color, arg) - return if @options[:for_engine][:quiet] - printf color(color, "%11s %s\n"), name, arg - end - - # Same as \{Kernel.puts}, but doesn't print anything if the `--quiet` option is set. - # - # @param args [Array] Passed on to \{Kernel.puts} - def puts(*args) - return if @options[:for_engine][:quiet] - Kernel.puts(*args) - end - - # Wraps the given string in terminal escapes - # causing it to have the given color. - # If terminal esapes aren't supported on this platform, - # just returns the string instead. - # - # @param color [Symbol] The name of the color to use. - # Can be `:red`, `:green`, or `:yellow`. - # @param str [String] The string to wrap in the given color. - # @return [String] The wrapped string. - def color(color, str) - raise "[BUG] Unrecognized color #{color}" unless COLORS[color] - - # Almost any real Unix terminal will support color, - # so we just filter for Windows terms (which don't set TERM) - # and not-real terminals, which aren't ttys. - return str if ENV["TERM"].nil? || ENV["TERM"].empty? || !STDOUT.tty? - return "\e[#{COLORS[color]}m#{str}\e[0m" - end - - private - - def open_file(filename, flag = 'r') - return if filename.nil? - flag = 'wb' if @options[:unix_newlines] && flag == 'w' - File.open(filename, flag) - end - - def handle_load_error(err) - dep = err.message[/^no such file to load -- (.*)/, 1] - raise err if @options[:trace] || dep.nil? || dep.empty? - $stderr.puts <] The command-line arguments - def initialize(args) - super - @options[:for_engine] = { - :load_paths => ['.'] + (ENV['SASSPATH'] || '').split(File::PATH_SEPARATOR) - } - @default_syntax = :sass - end - - protected - - # Tells optparse how to parse the arguments. - # - # @param opts [OptionParser] - def set_opts(opts) - super - - opts.banner = < e - raise e if @options[:trace] - raise e.sass_backtrace_str("standard input") - end - end - - private - - def load_compass - begin - require 'compass' - rescue LoadError - require 'rubygems' - begin - require 'compass' - rescue LoadError - puts "ERROR: Cannot load compass." - exit 1 - end - end - Compass.add_project_configuration - Compass.configuration.project_path ||= Dir.pwd - @options[:for_engine][:load_paths] += Compass.configuration.sass_load_paths - end - - def interactive - require 'sass/repl' - ::Sass::Repl.new(@options).run - end - - def watch_or_update - require 'sass/plugin' - ::Sass::Plugin.options.merge! @options[:for_engine] - ::Sass::Plugin.options[:unix_newlines] = @options[:unix_newlines] - - raise <>> Sass is watching for changes. Press Ctrl-C to stop." - - ::Sass::Plugin.on_template_modified {|template| puts ">>> Change detected to: #{template}"} - ::Sass::Plugin.on_template_created {|template| puts ">>> New template detected: #{template}"} - ::Sass::Plugin.on_template_deleted {|template| puts ">>> Deleted template detected: #{template}"} - - ::Sass::Plugin.watch(files) - end - - def colon_path?(path) - !split_colon_path(path)[1].nil? - end - - def split_colon_path(path) - one, two = path.split(':', 2) - if one && two && ::Sass::Util.windows? && - one =~ /\A[A-Za-z]\Z/ && two =~ /\A[\/\\]/ - # If we're on Windows and we were passed a drive letter path, - # don't split on that colon. - one2, two = two.split(':', 2) - one = one + ':' + one2 - end - return one, two - end - - # Whether path is likely to be meant as the destination - # in a source:dest pair. - def probably_dest_dir?(path) - return false unless path - return false if colon_path?(path) - return Dir.glob(File.join(path, "*.s[ca]ss")).empty? - end - end - - class Scss < Sass - # @param args [Array] The command-line arguments - def initialize(args) - super - @default_syntax = :scss - end - end - - # The `sass-convert` executable. - class SassConvert < Generic - # @param args [Array] The command-line arguments - def initialize(args) - super - require 'sass' - @options[:for_tree] = {} - @options[:for_engine] = {:cache => false, :read_cache => true} - end - - # Tells optparse how to parse the arguments. - # - # @param opts [OptionParser] - def set_opts(opts) - opts.banner = < e - raise e if @options[:trace] - file = " of #{e.sass_filename}" if e.sass_filename - raise "Error on line #{e.sass_line}#{file}: #{e.message}\n Use --trace for backtrace" - rescue LoadError => err - handle_load_error(err) - end - - @@less_note_printed = false - def try_less_note - return if @@less_note_printed - @@less_note_printed = true - warn < Object}] Options for the Sass file - # containing the `@import` that's currently being resolved. - # @return [Sass::Engine, nil] An Engine containing the imported file, - # or nil if it couldn't be found or was in the wrong format. - def find_relative(uri, base, options) - Sass::Util.abstract(self) - end - - # Find a Sass file, if it exists. - # - # This is the primary entry point of the Importer. - # It corresponds directly to an `@import` statement in Sass. - # It should do three basic things: - # - # * Determine if the URI is in this importer's format. - # If not, return nil. - # * Determine if the file indicated by the URI actually exists and is readable. - # If not, return nil. - # * Read the file and place the contents in a {Sass::Engine}. - # Return that engine. - # - # If this importer's format allows for file extensions, - # it should treat them the same way as the default {Filesystem} importer. - # If the URI explicitly has a `.sass` or `.scss` filename, - # the importer should look for that exact file - # and import it as the syntax indicated. - # If it doesn't exist, the importer should return nil. - # - # If the URI doesn't have either of these extensions, - # the importer should look for files with the extensions. - # If no such files exist, it should return nil. - # - # The {Sass::Engine} to be returned should be passed `options`, - # with a few modifications. `:filename` and `:syntax` should be set appropriately, - # and `:importer` should be set to this importer. - # - # @param uri [String] The URI to import. - # @param options [{Symbol => Object}] Options for the Sass file - # containing the `@import` that's currently being resolved. - # This is safe for subclasses to modify destructively. - # Callers should only pass in a value they don't mind being destructively modified. - # @return [Sass::Engine, nil] An Engine containing the imported file, - # or nil if it couldn't be found or was in the wrong format. - def find(uri, options) - Sass::Util.abstract(self) - end - - # Returns the time the given Sass file was last modified. - # - # If the given file has been deleted or the time can't be accessed - # for some other reason, this should return nil. - # - # @param uri [String] The URI of the file to check. - # Comes from a `:filename` option set on an engine returned by this importer. - # @param options [{Symbol => Objet}] Options for the Sass file - # containing the `@import` currently being checked. - # @return [Time, nil] - def mtime(uri, options) - Sass::Util.abstract(self) - end - - # Get the cache key pair for the given Sass URI. - # The URI need not be checked for validity. - # - # The only strict requirement is that the returned pair of strings - # uniquely identify the file at the given URI. - # However, the first component generally corresponds roughly to the directory, - # and the second to the basename, of the URI. - # - # Note that keys must be unique *across importers*. - # Thus it's probably a good idea to include the importer name - # at the beginning of the first component. - # - # @param uri [String] A URI known to be valid for this importer. - # @param options [{Symbol => Object}] Options for the Sass file - # containing the `@import` currently being checked. - # @return [(String, String)] The key pair which uniquely identifies - # the file at the given URI. - def key(uri, options) - Sass::Util.abstract(self) - end - - # A string representation of the importer. - # Should be overridden by subclasses. - # - # This is used to help debugging, - # and should usually just show the load path encapsulated by this importer. - # - # @return [String] - def to_s - Sass::Util.abstract(self) - end - end - end -end - - diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/importers/filesystem.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/importers/filesystem.rb deleted file mode 100644 index d78a275762..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/importers/filesystem.rb +++ /dev/null @@ -1,144 +0,0 @@ -require 'pathname' - -module Sass - module Importers - # The default importer, used for any strings found in the load path. - # Simply loads Sass files from the filesystem using the default logic. - class Filesystem < Base - - attr_accessor :root - - # Creates a new filesystem importer that imports files relative to a given path. - # - # @param root [String] The root path. - # This importer will import files relative to this path. - def initialize(root) - @root = root - end - - # @see Base#find_relative - def find_relative(name, base, options) - _find(File.dirname(base), name, options) - end - - # @see Base#find - def find(name, options) - _find(@root, name, options) - end - - # @see Base#mtime - def mtime(name, options) - file, s = find_real_file(@root, name) - File.mtime(file) if file - rescue Errno::ENOENT - nil - end - - # @see Base#key - def key(name, options) - [self.class.name + ":" + File.dirname(File.expand_path(name)), - File.basename(name)] - end - - # @see Base#to_s - def to_s - @root - end - - protected - - # If a full uri is passed, this removes the root from it - # otherwise returns the name unchanged - def remove_root(name) - root = @root.end_with?('/') ? @root : @root + '/' - if name.index(root) == 0 - name[root.length..-1] - else - name - end - end - - # A hash from file extensions to the syntaxes for those extensions. - # The syntaxes must be `:sass` or `:scss`. - # - # This can be overridden by subclasses that want normal filesystem importing - # with unusual extensions. - # - # @return [{String => Symbol}] - def extensions - {'sass' => :sass, 'scss' => :scss} - end - - # Given an `@import`ed path, returns an array of possible - # on-disk filenames and their corresponding syntaxes for that path. - # - # @param name [String] The filename. - # @return [Array(String, Symbol)] An array of pairs. - # The first element of each pair is a filename to look for; - # the second element is the syntax that file would be in (`:sass` or `:scss`). - def possible_files(name) - dirname, basename, extname = split(name) - sorted_exts = extensions.sort - syntax = extensions[extname] - - return [["#{dirname}/{_,}#{basename}.#{extensions.invert[syntax]}", syntax]] if syntax - sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]} - end - - - REDUNDANT_DIRECTORY = %r{#{Regexp.escape(File::SEPARATOR)}\.#{Regexp.escape(File::SEPARATOR)}} - # Given a base directory and an `@import`ed name, - # finds an existant file that matches the name. - # - # @param dir [String] The directory relative to which to search. - # @param name [String] The filename to search for. - # @return [(String, Symbol)] A filename-syntax pair. - def find_real_file(dir, name) - for (f,s) in possible_files(remove_root(name)) - path = (dir == ".") ? f : "#{dir}/#{f}" - if full_path = Dir[path].first - full_path.gsub!(REDUNDANT_DIRECTORY,File::SEPARATOR) - return full_path, s - end - end - nil - end - - # Splits a filename into three parts, a directory part, a basename, and an extension - # Only the known extensions returned from the extensions method will be recognized as such. - def split(name) - extension = nil - dirname, basename = File.dirname(name), File.basename(name) - if basename =~ /^(.*)\.(#{extensions.keys.map{|e| Regexp.escape(e)}.join('|')})$/ - basename = $1 - extension = $2 - end - [dirname, basename, extension] - end - - def hash - @root.hash - end - - def eql?(other) - root.eql?(other.root) - end - - private - - def _find(dir, name, options) - full_filename, syntax = find_real_file(dir, name) - return unless full_filename && File.readable?(full_filename) - - options[:syntax] = syntax - options[:filename] = full_filename - options[:importer] = self - Sass::Engine.new(File.read(full_filename), options) - end - - def join(base, path) - Pathname.new(base).join(path).to_s - end - end - end -end diff --git a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/less.rb b/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/less.rb deleted file mode 100755 index 71d63389bb..0000000000 --- a/jruby/src/main/resources/gem/gems/haml-3.1.1/vendor/sass/lib/sass/less.rb +++ /dev/null @@ -1,382 +0,0 @@ -#!/usr/bin/env ruby - -require 'less' - -module Less - # This is the class that Treetop defines for parsing Less files. - # Since not everything gets parsed into the AST but is instead resolved at parse-time, - # we need to override some of it so that it can be converted into Sass. - module StyleSheet - # Selector mixins that don't have arguments. - # This depends only on the syntax at the call site; - # if it doesn't use parens, it hits this production, - # regardless of whether the mixin being called has arguments or not. - module Mixin4 - def build_with_sass(env) - selectors.build(env, :mixin).each do |path| - el = path.inject(env.root) do |current, node| - current.descend(node.selector, node) or raise MixinNameError, "#{selectors.text_value} in #{env}" - end - if el.is_a?(Node::Mixin::Def) - # Calling a mixin with arguments, which gets compiled to a Sass mixin - env << Node::Mixin::Call.new(el, [], env) - else - # Calling a mixin without arguments, which gets compiled to @extend - sel = selector_str(path) - base = selector_str(selector_base(path)) - if base == sel - env << Node::SassNode.new(Sass::Tree::ExtendNode.new([sel])) - else - Sass::Util.sass_warn <