Comments (11)
Please expand, and how is this a bug?
from gnorm.
I removed the bug label... it was a misclick, but I can't remove the history of what happened (at least, I don't think so).
So... skylark is an embedded interpreter for skylark, which is a language that is essentially python-lite. It's exactly python syntax with some restrictions on what is and is not supported.
The nice thing is that python syntax is familiar to a lot of people (more so than Lua, the only other language offering an embedded interpreter in go). And it means that you can distribute plaintext files as plugins, with no external dependencies. That's a lot friendlier to end users.
from gnorm.
Ah! Okay, sorry I also missed the removed part, just saw the red flag and stopped there.
So you are saying adding native support for this? I thought the plugins as we know now have arisen from thinking in language agnostic way.
This can completely be handled by an external plugin that does skylark gymnastics leaving the gnorm binary to do what its best at i.e code generation.
Any ideas how you want to integrate this?
from gnorm.
interesting idea to have a plugin that handles skylark plugins. I like that it keeps the main gnorm code simpler.... but at the same time, it means you now have to worry about two executables when running any random gnorm build - gnorm and gnorm-sky (or whatever we'd call it)
I see skylark plugins as a really great option for people that want to distribute "themes" with no dependencies outside of the gnorm binary. For internal corporate use, you can just build any old binary plugin and not need to worry about the end user, because you know what your fellow devs will have installed on their workstation.
I don't exactly know how to integrate it yet, because I haven't had a chance to dive into skylark. I don't entirely understand how data gets into and out of a skylark plugin, for example (the API talks about setting global variables, but not entirely sure how that works in practice).
My idea is that it'll work basically like plugins do now. you say {{plugin "foo.sky" "funcName" .}}
and then gnorm knows that because it's a .sky file, it should run it using the embedded skylark interpreter and somehow pass the data to the given function (that part I don't know how to do, or if there's a better way to do it given the way skylark works).
from gnorm.
A quick glance on skylark godoc shows that the globals doesn't mean global env vars as we know, more like global context on the program/file execution.
Still, I believe my idea to outsource skylark support is solid. We introduced plugins to allow extending the functionality without jeopardizing gnorm sanity.
So, here is what I am thinking.
Say you have a file dark.sky
assuming the extension is .sky
and you want to execute the file with the skylark plugin.
First, our current plugin is limiting in the number of arguments and contexts to pass. i.e
{{plugin "skylark" "dark.sky" . }}
this will execute the file and render the output. However we might want to pass custom settings or call them flags to the plugin to add more context, like providing the global values for execution in addition to the context e.t.c.
One easy workaround is to add a helper function for assigning values to maps or slices, which returns new maps or slices with the new values added.
{{assign . "level" 4}
provided context is a map[string]interface{}
will return a new map with copies of original context and m["level"]=4
.
This way the plugin will be extremely configurable.
The whole point of custom directories for plugins is for people serious enough with what they run i.e corporate e.t.c . If they were happy enough to have the gnorm binary it won't hurt them to have skylark plugin binary that they can ship with the templates.
from gnorm.
FYI - this is a good example of how to actually use skylark: https://github.com/google/skylark/blob/master/example_test.go#L21
from gnorm.
Very neat, maybe they were targeting embedding of the interpreter in Go.
from gnorm.
Yeah, that's exactly what I'm talking about - having the interpreter embedded in Go, so that plugin authors just need to write a .sky file and gnorm can run them with a few lines of code that imports the skylark package.... no external binary needed.
from gnorm.
Since the external plugin will still be a go program that embeds the interpreter. Instead of guessing, how about we start with external plugin, and when users like it enough we can add native support for it.
I'm skeptic because today is like the first time I heard about skylark, and natively supporting a feature that has no users is an overkill.
from gnorm.
that is a really really good point :) . I agree. :)
from gnorm.
relevant link https://github.com/natefinch/skyhook
from gnorm.
Related Issues (20)
- mssql support HOT 1
- sqlite support HOT 2
- Versus on website is disingenuous towards sqlboiler HOT 5
- Add useful default templates HOT 16
- Gnorm does not seem to work with recent mysql version (v8) HOT 2
- MariaDB, Error: name "GENERATION_EXPRESSION": unsupported Scan HOT 1
- Schema.Enums contains one value for each value instead of each type HOT 9
- Support for keyword table names in Postgres
- gnorm do not recognize default value from identity
- ForeignKeyRefs being overwritten
- Support for TableType HOT 1
- Is this project dead ? HOT 4
- Error : function "plural" not defined
- Is there a Protobuf example? HOT 8
- Build instructions don't work as given HOT 5
- Build instructions don't match the source code
- Why am I getting this? Error: error scanning foreign key constraint: sql: Scan error on column index 5, name "table_name": converting NULL to string is unsupported HOT 12
- pq version does not work with postgres 10 HOT 2
- database/drives/postgres/parse.go::queryEnums query adds an enum per enum value rather than actual enum HOT 2
- Table name is unknown in enum generation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnorm.