Created
April 20, 2011 12:11
-
-
Save julienrf/931135 to your computer and use it in GitHub Desktop.
Is it possible to write more expressive things?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tyco.compiler._ | |
object MyWebsite extends tyco.Site { | |
for (page <- Content.allPages) | |
page.uri ==> Template.show(page) | |
for (file <- Path("stylesheets/*.scss")) | |
"/css/"+file.name ==> new TextFile(file) with Sass with CssMinifier | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That’s not only the arrows, but all the different ways to handle the different intents of the webmaster:
for (page <- content.pages) { ... }
) to retrieve the data of the webpages (e.g. from a database) ;new TextFile(file) with Sass with CssMinifier
) ;Given this website description you can generate the full website just by calling
MyWebsite.compile()
(cf my website).Ok, there are still some noisy characters (namely braces or import statements) but I think the huge benefit of this compromise (an embedded DSL instead of a standalone own language) is that I didn’t need to implement a full compiler. I just wrote the missing delta between scala primitives and my DSL primitives, so that I can reuse the whole scala compiler infrastructure, its type system, etc. It gives me a lot of expression power as long as very high-level abstractions.